Пример #1
0
 @Override
 public int compareTo(Duration otherDuration) {
   int cmp = Long.compare(seconds, otherDuration.seconds);
   if (cmp != 0) {
     return cmp;
   }
   return nanos - otherDuration.nanos;
 }
Пример #2
0
  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);
    }
  }