Example #1
0
  public static long parseTime(String timeString) throws ParseException {
    // parsing lapTime
    String[] stringElements = timeString.split(":");
    if (stringElements.length != 2 && stringElements.length != 3) {
      throw new ParseException(timeString, 0);
    }
    long[] longElements = new long[stringElements.length];
    for (int i = 0; i < stringElements.length; i++) {
      try {
        longElements[i] = Long.parseLong(stringElements[i]);
        if (longElements[i] < 0 || longElements[i] >= 60) {
          throw new ParseException(timeString, 0);
        }
      } catch (NumberFormatException e) {
        throw new ParseException(timeString, 0);
      }
    }

    final long lapTime;
    if (longElements.length == 3) {
      lapTime = (longElements[0] * 60 * 60 + longElements[1] * 60 + longElements[2]) * 1000;
    } else {
      lapTime = (longElements[0] * 60 + longElements[1]) * 1000;
    }
    return lapTime;
  }
Example #2
0
  public static int compareLong(Long o1Long, Long o2Long) {
    if (o1Long == null) o1Long = 0L;
    if (o2Long == null) o2Long = 0L;

    return o1Long.compareTo(o2Long);
  }