From 035db16b87e0687bd77dc6a3d696bfd9be3080d1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 17 Nov 2005 14:03:22 +0000 Subject: [multiple changes] 2005-11-17 Mark Wielaard * java/text/SimpleDateFormat.java: Removed, fully merged now. * sources.am: Regenerated. * Makefile.in: Regenerated. 2005-11-17 Sven de Marothy * java/text/SimpleDateFormat.java (computeOffset): Allow timezone to be first in the parsed String. 2005-11-17 Mark Wielaard * java/text/SimpleDateFormat.java (field, size): Make package private. 2005-11-17 Tom Tromey * java/text/SimpleDateFormat.java (compileFormat): Correctly handle quoted single quotes. PR classspath/23183. 2005-11-17 Tom Tromey * java/text/SimpleDateFormat.java (compileFormat): Reformatted. 2005-11-17 Tom Tromey * java/text/DateFormat.java (serialVersionUID): New field. 2005-11-17 Mark Wielaard * java/text/DateFormat.java (equals): Reimplement. 2005-11-17 David Gilbert * java/text/Collator.java: API doc fixes, * java/text/DateFormat.java: likewise, * java/text/DecimalFormatSymbols.java: likewise, * java/text/DateFormatSymbols.java: likewise, * java/text/SimpleDateFormat.java: likewise. 2005-11-17 Jeroen Frijters * java/text/Collator.java (getInstance(Locale)): Added default collation pattern to handle case when resource is missing and throw InternalError instead of returning null should parsing fail. From-SVN: r107121 --- libjava/java/text/DateFormat.java | 55 ++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'libjava/java/text/DateFormat.java') diff --git a/libjava/java/text/DateFormat.java b/libjava/java/text/DateFormat.java index 8cf60ae..c94d984 100644 --- a/libjava/java/text/DateFormat.java +++ b/libjava/java/text/DateFormat.java @@ -58,6 +58,9 @@ import java.util.TimeZone; public abstract class DateFormat extends Format implements Cloneable { + private static final long serialVersionUID = 7218322306649953788L; + + // Names fixed by serialization spec. protected Calendar calendar; protected NumberFormat numberFormat; @@ -405,8 +408,18 @@ public abstract class DateFormat extends Format implements Cloneable *
    *
  • Is not null.
  • *
  • Is an instance of DateFormat.
  • - *
  • Has the same numberFormat field value as this object.
  • + *
  • Has equal numberFormat field as this object.
  • + *
  • Has equal (Calendar) TimeZone rules as this object.
  • + *
  • Has equal (Calendar) isLenient results.
  • + *
  • Has equal Calendar first day of week and minimal days in week + * values.
  • *
+ * Note that not all properties of the Calendar are relevant for a + * DateFormat. For formatting only the fact whether or not the + * TimeZone has the same rules and whether the calendar is lenient + * and has the same week rules is compared for this implementation + * of equals. Other properties of the Calendar (such as the time) + * are not taken into account. * * @param obj The object to test for equality against. * @@ -419,8 +432,24 @@ public abstract class DateFormat extends Format implements Cloneable return false; DateFormat d = (DateFormat) obj; - - return numberFormat.equals(d.numberFormat); + TimeZone tz = getTimeZone(); + TimeZone tzd = d.getTimeZone(); + if (tz.hasSameRules(tzd)) + if (isLenient() == d.isLenient()) + { + Calendar c = getCalendar(); + Calendar cd = d.getCalendar(); + if ((c == null && cd == null) + || + (c.getFirstDayOfWeek() == cd.getFirstDayOfWeek() + && + c.getMinimalDaysInFirstWeek() + == cd.getMinimalDaysInFirstWeek())) + return ((numberFormat == null && d.numberFormat == null) + || numberFormat.equals(d.numberFormat)); + } + + return false; } /** @@ -442,9 +471,9 @@ public abstract class DateFormat extends Format implements Cloneable * thrown. * * @param obj The Object to format. - * @param toAppendTo The StringBuffer to append the resultant + * @param buf The StringBuffer to append the resultant * String to. - * @param fieldPosition Is updated to the start and end index of the + * @param pos Is updated to the start and end index of the * specified field. * * @return The StringBuffer supplied on input, with the @@ -479,9 +508,9 @@ public abstract class DateFormat extends Format implements Cloneable * to the specified StringBuffer. * * @param date The Date value to format. - * @param toAppendTo The StringBuffer to append the resultant + * @param buf The StringBuffer to append the resultant * String to. - * @param fieldPosition Is updated to the start and end index of the + * @param pos Is updated to the start and end index of the * specified field. * * @return The StringBuffer supplied on input, with the @@ -646,7 +675,7 @@ public abstract class DateFormat extends Format implements Cloneable * localed will be used in place of the default. * * @param style The type of formatting to perform. - * @param aLocale The desired locale. + * @param loc The desired locale. * * @return A new DateFormat instance. */ @@ -747,7 +776,7 @@ public abstract class DateFormat extends Format implements Cloneable * localed will be used in place of the default. * * @param style The type of formatting to perform. - * @param aLocale The desired locale. + * @param loc The desired locale. * * @return A new DateFormat instance. */ @@ -821,7 +850,7 @@ public abstract class DateFormat extends Format implements Cloneable * starting parse position on method entry and the ending parse * position on method exit. * - * @param text The string to parse. + * @param source The string to parse. * @param pos The starting parse position in entry, the ending parse * position on exit. * @@ -851,7 +880,7 @@ public abstract class DateFormat extends Format implements Cloneable * This method specified the Calendar that should be used * by this object to parse/format datetimes. * - * @param The new Calendar for this object. + * @param calendar The new Calendar for this object. * * @see java.util.Calendar */ @@ -876,7 +905,7 @@ public abstract class DateFormat extends Format implements Cloneable * This method specifies the NumberFormat object that should * be used by this object to parse/format times. * - * @param The NumberFormat in use by this object. + * @param numberFormat The NumberFormat in use by this object. */ public void setNumberFormat (NumberFormat numberFormat) { @@ -886,7 +915,7 @@ public abstract class DateFormat extends Format implements Cloneable /** * This method sets the time zone that should be used by this object. * - * @param The new time zone. + * @param timeZone The new time zone. */ public void setTimeZone (TimeZone timeZone) { -- cgit v1.1