Performs a comparison of the two points in time represented by two
Timestamps.
If the point in time represented by this Timestamp precedes that of
t, then
-1 is returned.
If
t precedes this Timestamp then
1 is returned.
If the Timestamps represent the same point in time, then
0 is returned.
Note that a
0 result does not imply that the two Timestamps are
#equals, as the local offset or precision of the two Timestamps
may be different.
This method is provided in preference to individual methods for each of
the six boolean comparison operators (<, ==, >, >=, !=, <=).
The suggested idiom for performing these comparisons is:
(x.compareTo(y)<op>
0),
where <op> is one of the six comparison operators.
For example, the pairs below will return a
0 result:
-
2009T
-
2009-01T
-
2009-01-01T
-
2009-01-01T00:00Z
-
2009-01-01T00:00:00Z
-
2009-01-01T00:00:00.0Z
-
2009-01-01T00:00:00.00Z
-
2008-12-31T16:00-08:00
-
2008-12-31T12:00-12:00
-
2009-01-01T12:00+12:00
Use the
#equals(Timestamp) method to compare the point
in time, including precision and local offset.