Duration implements Comparable<Duration> { @Override public boolean equals(Object obj) { if (obj instanceof Duration) { return duration.equals(((Duration) obj).duration); } return false; } Duration(String value);  Duration(long value); @Override boolean equals(Object obj); @Override int hashCode(); java.time.Duration getDuration(); @Override int compareTo(Duration o); @Override String toString(); static final Duration ZERO; }
@Test public void testEquals() { Duration d1 = new Duration("1s"); Duration d2 = new Duration("2s"); Duration d3 = new Duration("1 sec"); Duration d4 = new Duration("1000ms"); Duration d5 = new Duration("1.1s"); Duration d6 = new Duration("1100ms"); assertTrue(d1.equals(d1)); assertFalse(d1.equals(null)); assertFalse(d1.equals(d2)); assertTrue(d1.equals(d3)); assertTrue(d1.equals(d4)); assertTrue(d4.equals(d1)); assertTrue(d5.equals(d6)); }