@Test public void testDivide() { Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toDays()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toHours()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMicroseconds()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMilliseconds()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMinutes()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toNanoseconds()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toSeconds()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toMillisecondsIntBound()); Assert.assertEquals(0, TimeValue.ofMilliseconds(0).divide(2).toSecondsIntBound()); Assert.assertEquals(50, TimeValue.ofMilliseconds(100).divide(2).toMilliseconds()); Assert.assertEquals(0, TimeValue.ofMinutes(1).divide(2).toSeconds()); Assert.assertEquals(30, TimeValue.ofMinutes(1).divide(2, TimeUnit.SECONDS).toSeconds()); Assert.assertEquals(30000, TimeValue.ofMinutes(1).divide(2, TimeUnit.MILLISECONDS).toMilliseconds()); }
public TimeValue divide(final long divisor) { final long newDuration = duration / divisor; return of(newDuration, timeUnit); }
TimeValue implements Comparable<TimeValue> { public TimeValue divide(final long divisor) { final long newDuration = duration / divisor; return of(newDuration, timeUnit); } }
TimeValue implements Comparable<TimeValue> { public TimeValue divide(final long divisor) { final long newDuration = duration / divisor; return of(newDuration, timeUnit); } TimeValue(final long duration, final TimeUnit timeUnit); }
TimeValue implements Comparable<TimeValue> { public TimeValue divide(final long divisor) { final long newDuration = duration / divisor; return of(newDuration, 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(); }
TimeValue implements Comparable<TimeValue> { public TimeValue divide(final long divisor) { final long newDuration = duration / divisor; return of(newDuration, 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; }