Duration implements Comparable<Duration> { @JsonValue @Override public String toString() { return toString(unit); } Duration(double value, TimeUnit unit); static Duration nanosSince(long start); static Duration succinctNanos(long nanos); static Duration succinctDuration(double value, TimeUnit unit); long toMillis(); double getValue(); TimeUnit getUnit(); double getValue(TimeUnit timeUnit); long roundTo(TimeUnit timeUnit); Duration convertToMostSuccinctTimeUnit(); @JsonValue @Override String toString(); String toString(TimeUnit timeUnit); @JsonCreator static Duration valueOf(String duration); @Override int compareTo(Duration o); @Override boolean equals(Object o); @Override int hashCode(); static TimeUnit valueOfTimeUnit(String timeUnitString); static String timeUnitToString(TimeUnit timeUnit);  }
@Test(dataProvider = "printedValues") public void testToString(String expectedString, double value, TimeUnit unit) { assertEquals(new Duration(value, unit).toString(), expectedString); }
@Test(dataProvider = "printedValues") public void testNonEnglishLocale(String expectedString, double value, TimeUnit unit) { synchronized (Locale.class) { Locale previous = Locale.getDefault(); Locale.setDefault(Locale.GERMAN); try { assertEquals(new Duration(value, unit).toString(), expectedString); } finally { Locale.setDefault(previous); } } }