TimeRange implements Comparable<TimeRange> { public long toMillis() { return timeUnit.toMillis( duration ); } TimeRange(@JsonProperty("duration") long duration,
                     @JsonProperty("timeUnit") TimeUnit timeUnit); long getDuration(); TimeUnit getTimeUnit(); TimeRange convert(TimeUnit timeUnit); long toMillis(); long toSeconds(); long get(TimeUnit targetTimeUnit); @Override int compareTo(TimeRange o); @Override boolean equals(Object o); @Override int hashCode(); String format(); @Override String toString(); static TimeRange ofMillis(long millis); static TimeRange ofSeconds(long seconds); static TimeRange ofMinutes(long minutes); static TimeRange ofHours(long hours); static TimeRange ofDays(long days); static TimeRange ofWeeks(long weeks); static TimeRange MAX_RANGE; }
@Test public void testGetTimeMillis() throws Exception { TimeRange tr = new TimeRange( 5, TimeUnit.MINUTES ); assertEquals( 5 * 60 * 1000, tr.toMillis() ); tr = new TimeRange( 5 * 60 * 1000, TimeUnit.MILLISECONDS ); assertEquals( 5 * 60 * 1000, tr.toMillis() ); }