compareTo()

Compares the time values (millisecond offsets from the Epoch) represented by two Calendar objects.

Syntax

Numeric compareTo(Calendar other)
  1. other is the calendar to compare.

Usage

For example, to compare the two time values represented by 08/31/1999 and 09/31/1999, use:
Calendar.fromDate(Date.parseString("08/31/1999","mm/dd/yyyy")).compareTo(Calendar.fromDate(Date.parseString("09/31/1999","mm/dd/yyyy")))

The time value is expressed in millisecond offsets from the Epoch January 1, 1970 00:00:00.000 GMT Gregorian.

This method returns:

  • 0 if the time represented by the argument is equal to the time represented by this Calendar.
  • A value less than 0 if the time of this Calendar is before the time represented by the argument.
  • A value greater than 0 if the time of this Calendar is after the time represented by the argument.