Index: java/util/Calendar.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v retrieving revision 1.25.2.13 diff -u -3 -p -u -r1.25.2.13 Calendar.java --- java/util/Calendar.java 13 Mar 2005 14:38:42 -0000 1.25.2.13 +++ java/util/Calendar.java 19 Apr 2005 23:09:43 -0000 @@ -1176,11 +1176,29 @@ public abstract class Calendar return max; } - public int compareTo(Calendar other) + /** + * Compares the time of two calendar instances. + * @param calendar the calendar to which the time should be compared. + * @return 0 if the two calendars are set to the same time, + * less than 0 if the time of this calendar is before that of + * cal, or more than 0 if the time of this calendar is after + * that of cal. + * + * @param cal the calendar to compare this instance with. + * @throws NullPointerException if cal is null. + * @throws IllegalArgumentException if either calendar has fields set to + * invalid values. + * @since 1.5 + */ + public int compareTo(Calendar cal) { - if (time < other.time) - return -1; - return time == other.time ? 0 : 1; + long t1 = getTimeInMillis(); + long t2 = cal.getTimeInMillis(); + if(t1 == t2) + return 0; + if(t1 > t2) + return 1; + return -1; } /**