diff --git a/icu4j/src/com/ibm/icu/util/Calendar.java b/icu4j/src/com/ibm/icu/util/Calendar.java index 2c2ef5935de..262a970b933 100755 --- a/icu4j/src/com/ibm/icu/util/Calendar.java +++ b/icu4j/src/com/ibm/icu/util/Calendar.java @@ -620,7 +620,7 @@ import java.util.ResourceBundle; * @see GregorianCalendar * @see TimeZone * @see DateFormat - * @version $Revision: 1.29 $ $Date: 2002/08/08 01:45:21 $ + * @version $Revision: 1.30 $ $Date: 2002/08/21 18:39:56 $ * @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu, Laura Werner * @since JDK1.1 */ @@ -1685,12 +1685,26 @@ public abstract class Calendar implements Serializable, Cloneable { Calendar that = (Calendar) obj; - return - getTimeInMillis() == that.getTime().getTime() && - isLenient() == that.isLenient() && - getFirstDayOfWeek() == that.getFirstDayOfWeek() && - getMinimalDaysInFirstWeek() == that.getMinimalDaysInFirstWeek() && - getTimeZone().equals(that.getTimeZone()); + return isEquivalentTo(that) && + getTimeInMillis() == that.getTime().getTime(); + } + + /** + * Returns true if the given Calendar object is equivalent to this + * one. An equivalent Calendar will behave exactly as this one + * does, but it may be set to a different time. By contrast, for + * the equals() method to return true, the other Calendar must + * be set to the same time. + * + * @param other the Calendar to be compared with this Calendar + * @since ICU 2.4 + */ + public boolean isEquivalentTo(Calendar other) { + return this.getClass() == other.getClass() && + isLenient() == other.isLenient() && + getFirstDayOfWeek() == other.getFirstDayOfWeek() && + getMinimalDaysInFirstWeek() == other.getMinimalDaysInFirstWeek() && + getTimeZone().equals(other.getTimeZone()); } /** diff --git a/icu4j/src/com/ibm/icu/util/GregorianCalendar.java b/icu4j/src/com/ibm/icu/util/GregorianCalendar.java index beca53f80c3..a145453fa51 100755 --- a/icu4j/src/com/ibm/icu/util/GregorianCalendar.java +++ b/icu4j/src/com/ibm/icu/util/GregorianCalendar.java @@ -480,16 +480,17 @@ public class GregorianCalendar extends Calendar { } /** - * Compares this GregorianCalendar to an object reference. - * @param obj the object reference with which to compare - * @return true if this object is equal to obj; false otherwise + * Returns true if the given Calendar object is equivalent to this + * one. Calendar override. + * + * @param other the Calendar to be compared with this Calendar + * @since ICU 2.4 */ - public boolean equals(Object obj) { - return super.equals(obj) && - // Calendar.equals() ensures obj instanceof GregorianCalendar - gregorianCutover == ((GregorianCalendar)obj).gregorianCutover; + public boolean isEquivalentTo(Calendar other) { + return super.isEquivalentTo(other) && + gregorianCutover == ((GregorianCalendar)other).gregorianCutover; } - + /** * Override hashCode. * Generates the hash code for the GregorianCalendar object