@Test public void testSimpleCompare() { Duration d1 = new Duration(100); Duration d2 = new Duration(200); assertThat(sign(d1.compareTo(d2)), is(-1)); assertThat(sign(d2.compareTo(d1)), is(1)); assertThat(d1.compareTo(d1), is(0)); assertThat(d2.compareTo(d2), is(0)); }
public int compareTo(Duration o) { long diff = millis()-o.millis(); return diff < 0 ? -1 : diff > 0 ? 1 : 0; }
Duration implements Comparable<Duration> { public int compareTo(Duration o) { long diff = millis()-o.millis(); return diff < 0 ? -1 : diff > 0 ? 1 : 0; } }
Duration implements Comparable<Duration> { public int compareTo(Duration o) { long diff = millis()-o.millis(); return diff < 0 ? -1 : diff > 0 ? 1 : 0; } Duration(Date start, Date end);  Duration(long duration, TimeUnit units);  Duration(long durationInMillis); }
Duration implements Comparable<Duration> { public int compareTo(Duration o) { long diff = millis()-o.millis(); return diff < 0 ? -1 : diff > 0 ? 1 : 0; } Duration(Date start, Date end);  Duration(long duration, TimeUnit units);  Duration(long durationInMillis); long millis(); String toString(); int compareTo(Duration o); @Override int hashCode(); @Override boolean equals(Object obj); }
Duration implements Comparable<Duration> { public int compareTo(Duration o) { long diff = millis()-o.millis(); return diff < 0 ? -1 : diff > 0 ? 1 : 0; } Duration(Date start, Date end);  Duration(long duration, TimeUnit units);  Duration(long durationInMillis); long millis(); String toString(); int compareTo(Duration o); @Override int hashCode(); @Override boolean equals(Object obj);  }