@Override public int compareTo(Duration otherDuration) { int cmp = Long.compare(seconds, otherDuration.seconds); if (cmp != 0) { return cmp; } return nanos - otherDuration.nanos; }
private static long parseNumber( CharSequence text, String parsed, int multiplier, String errorText) { if (parsed == null) { return 0; } try { long val = Long.parseLong(parsed); return Math.multiplyExact(val, multiplier); } catch (NumberFormatException | ArithmeticException ex) { throw (DateTimeParseException) new DateTimeParseException("Text cannot be parsed to a Duration: " + errorText, text, 0) .initCause(ex); } }