TimeValue implements Comparable<TimeValue> { public long convert(final TimeUnit targetTimeUnit) { Args.notNull(targetTimeUnit, "timeUnit"); return targetTimeUnit.convert(duration, timeUnit); } TimeValue(final long duration, final TimeUnit timeUnit); static int asBoundInt(final long value); static T defaultsTo(final T timeValue, final T defaultValue); static TimeValue defaultsToNegativeOneMillisecond(final TimeValue timeValue); static TimeValue defaultsToNegativeOneSecond(final TimeValue timeValue); static TimeValue defaultsToZeroMilliseconds(final TimeValue timeValue); static boolean isNonNegative(final TimeValue timeValue); static boolean isPositive(final TimeValue timeValue); static TimeValue of(final long duration, final TimeUnit timeUnit); static TimeValue ofDays(final long days); static TimeValue ofHours(final long hours); static TimeValue ofMicroseconds(final long microseconds); static TimeValue ofMilliseconds(final long millis); static TimeValue ofMinutes(final long minutes); static TimeValue ofNanoseconds(final long nanoseconds); static TimeValue ofSeconds(final long seconds); static TimeValue parse(final String value); long convert(final TimeUnit targetTimeUnit); @Override boolean equals(final Object obj); TimeValue divide(final long divisor); TimeValue divide(final long divisor, final TimeUnit targetTimeUnit); long getDuration(); TimeUnit getTimeUnit(); @Override int hashCode(); TimeValue min(final TimeValue other); void sleep(); void timedJoin(final Thread thread); void timedWait(final Object obj); long toDays(); long toHours(); long toMicroseconds(); long toMilliseconds(); int toMillisecondsIntBound(); long toMinutes(); long toNanoseconds(); long toSeconds(); int toSecondsIntBound(); @Override int compareTo(final TimeValue other); @Override String toString(); Timeout toTimeout(); static final TimeValue MAX_VALUE; static final TimeValue NEG_ONE_MILLISECOND; static final TimeValue NEG_ONE_SECOND; static final TimeValue ZERO_MILLISECONDS; }
@Test public void testConvert() { Assert.assertEquals(0, TimeValue.ofMilliseconds(0).convert(TimeUnit.DAYS)); Assert.assertEquals(1000, TimeValue.ofSeconds(1).convert(TimeUnit.MILLISECONDS)); }