/**
   * Parses the time to verify that time is in correct time format [HH:mm:ss]
   *
   * @throws IllegalTimeFormatException - throws com.berlinconverter.util.IllegalTimeFormatException
   *     whenever the given time String object is of wrong format
   * @throws java.lang.NullPointerException - throws NullPointerException in case provided time
   *     String object is null
   */
  private Clock parse(String time) throws IllegalTimeFormatException, NullPointerException {

    if (time == null) throw new NullPointerException("Time is null");

    if (!time.matches(Constants.DATE_FORMAT))
      throw new IllegalTimeFormatException("Wrong date format provided");

    Clock clock = new Clock();

    String clockParts[] = time.split(":");

    int hours = Integer.parseInt(clockParts[0]);
    int minutes = Integer.parseInt(clockParts[1]);
    int seconds = Integer.parseInt(clockParts[2]);

    if (hours > 24 || minutes > 60 || seconds > 60)
      throw new IllegalTimeFormatException("Time is not in a correct format");

    clock.setHours(hours);
    clock.setMinutes(minutes);
    clock.setSeconds(seconds);

    return clock;
  }