@Test public void testCompareTo() throws Exception { Timestamp t = new Timestamp(); t.setLogical((short)2); Timestamp tfuture1 = t.add(1, (short)0); Timestamp tfuture2 = t.add(0, (short)1); Timestamp tpast1 = t.add(-1, (short)1); Timestamp tpast2 = t.add(0, (short)-1); Timestamp tSame = t.clone(); assertTrue(t.compareTo(tfuture1) < 0); assertTrue(t.compareTo(tfuture2) < 0); assertTrue(t.compareTo(tpast1) > 0); assertTrue(t.compareTo(tpast2) > 0); assertTrue(t.compareTo(tSame) == 0); }
public int compareTo(Timestamp o) { if (this.wallTime < o.wallTime || (this.wallTime == o.wallTime && this.logical < o.logical)) { return -1; } else if (this.wallTime > o.wallTime || (this.wallTime == o.wallTime && this.logical > o.logical)) { return 1; } return 0; }
Timestamp implements Comparable<Timestamp>, Cloneable { public int compareTo(Timestamp o) { if (this.wallTime < o.wallTime || (this.wallTime == o.wallTime && this.logical < o.logical)) { return -1; } else if (this.wallTime > o.wallTime || (this.wallTime == o.wallTime && this.logical > o.logical)) { return 1; } return 0; } }
Timestamp implements Comparable<Timestamp>, Cloneable { public int compareTo(Timestamp o) { if (this.wallTime < o.wallTime || (this.wallTime == o.wallTime && this.logical < o.logical)) { return -1; } else if (this.wallTime > o.wallTime || (this.wallTime == o.wallTime && this.logical > o.logical)) { return 1; } return 0; } Timestamp();  Timestamp(long wallTime, short logical);  Timestamp(long t); }
Timestamp implements Comparable<Timestamp>, Cloneable { public int compareTo(Timestamp o) { if (this.wallTime < o.wallTime || (this.wallTime == o.wallTime && this.logical < o.logical)) { return -1; } else if (this.wallTime > o.wallTime || (this.wallTime == o.wallTime && this.logical > o.logical)) { return 1; } return 0; } Timestamp();  Timestamp(long wallTime, short logical);  Timestamp(long t); Timestamp clone(); Timestamp add(Timestamp t); Timestamp add(long wallTime, short logical); long getWallTime(); void setWallTime(long wallTime); short getLogical(); void setLogical(short logical); void incrementLogical(); void resetLogical(); long toLong(); int compareTo(Timestamp o); String toString(); }
Timestamp implements Comparable<Timestamp>, Cloneable { public int compareTo(Timestamp o) { if (this.wallTime < o.wallTime || (this.wallTime == o.wallTime && this.logical < o.logical)) { return -1; } else if (this.wallTime > o.wallTime || (this.wallTime == o.wallTime && this.logical > o.logical)) { return 1; } return 0; } Timestamp();  Timestamp(long wallTime, short logical);  Timestamp(long t); Timestamp clone(); Timestamp add(Timestamp t); Timestamp add(long wallTime, short logical); long getWallTime(); void setWallTime(long wallTime); short getLogical(); void setLogical(short logical); void incrementLogical(); void resetLogical(); long toLong(); int compareTo(Timestamp o); String toString();  }