TimeRange implements Comparable<TimeRange> { public long get(TimeUnit targetTimeUnit) { return targetTimeUnit.convert(duration, timeUnit); } 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 testGet() throws Exception { assertEquals(60, TimeRange.ofMinutes(1).get(TimeUnit.SECONDS)); assertEquals(60_000, TimeRange.ofMinutes(1).get(TimeUnit.MILLISECONDS)); }