From: Michael Koch Date: Sat, 21 Jun 2003 12:42:26 +0000 (+0000) Subject: DateFormat.java, [...]: New versions from classpath. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=73c7dd50e8f9b03e6fbc64212566d1a2d603aed2;p=gcc.git DateFormat.java, [...]: New versions from classpath. 2003-06-21 Michael Koch * java/text/DateFormat.java, java/text/SimpleDateFormat.java, java/util/Locale.java: New versions from classpath. From-SVN: r68300 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 34a9282883a..2c847901c30 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2003-06-21 Michael Koch + + * java/text/DateFormat.java, + java/text/SimpleDateFormat.java, + java/util/Locale.java: + New versions from classpath. + 2003-06-21 Michael Koch * javax/swing/SpinnerModel.java: diff --git a/libjava/java/text/DateFormat.java b/libjava/java/text/DateFormat.java index c298ef23342..df2b270e4f3 100644 --- a/libjava/java/text/DateFormat.java +++ b/libjava/java/text/DateFormat.java @@ -101,7 +101,7 @@ public abstract class DateFormat extends Format implements Cloneable *
    *
  • Is not null. *
  • Is an instance of DateFormat. - *
  • Has the same calendar and numberFormat field values as this object. + *
  • Has the same numberFormat field value as this object. *
* * @param obj The object to test for equality against. @@ -111,10 +111,12 @@ public abstract class DateFormat extends Format implements Cloneable */ public boolean equals (Object obj) { - if (! (obj instanceof DateFormat)) + if (!(obj instanceof DateFormat)) return false; + DateFormat d = (DateFormat) obj; - return calendar.equals(d.calendar) && numberFormat.equals(d.numberFormat); + + return numberFormat.equals(d.numberFormat); } /** @@ -467,10 +469,10 @@ public abstract class DateFormat extends Format implements Cloneable */ public int hashCode () { - int hash = calendar.hashCode(); if (numberFormat != null) - hash ^= numberFormat.hashCode(); - return hash; + return numberFormat.hashCode(); + else + return 0; } /** diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java index 7b282f3c62f..67523e1628d 100644 --- a/libjava/java/text/SimpleDateFormat.java +++ b/libjava/java/text/SimpleDateFormat.java @@ -384,10 +384,10 @@ public class SimpleDateFormat extends DateFormat SimpleDateFormat sdf = (SimpleDateFormat)o; - if (!toPattern().equals(sdf.toPattern())) + if (defaultCentury != sdf.defaultCentury) return false; - if (!get2DigitYearStart().equals(sdf.get2DigitYearStart())) + if (!toPattern().equals(sdf.toPattern())) return false; if (!getDateFormatSymbols().equals(sdf.getDateFormatSymbols())) @@ -396,6 +396,17 @@ public class SimpleDateFormat extends DateFormat return true; } + /** + * This method returns a hash value for this object. + * + * @return A hash value for this object. + */ + public int hashCode() + { + return super.hashCode() ^ toPattern().hashCode() ^ defaultCentury ^ + getDateFormatSymbols().hashCode(); + } + /** * Formats the date input according to the format string in use, diff --git a/libjava/java/util/Locale.java b/libjava/java/util/Locale.java index 60fdd0ad93b..431824f0c35 100644 --- a/libjava/java/util/Locale.java +++ b/libjava/java/util/Locale.java @@ -231,9 +231,9 @@ public final class Locale implements Serializable, Cloneable // default locale. if (defaultLocale != null) { - language = convertLanguage(language); - country = country.toUpperCase(); - variant = variant.toUpperCase(); + language = convertLanguage(language).intern(); + country = country.toUpperCase().intern(); + variant = variant.toUpperCase().intern(); } this.language = language; this.country = country; @@ -436,7 +436,7 @@ public final class Locale implements Serializable, Cloneable */ public String getISO3Language() { - if ("".equals(language)) + if (language == "") return ""; int index = ("aa,ab,af,am,ar,as,ay,az,ba,be,bg,bh,bi,bn,bo,br,ca,co,cs,cy,da," @@ -472,7 +472,7 @@ public final class Locale implements Serializable, Cloneable */ public String getISO3Country() { - if ("".equals(country)) + if (country == "") return ""; int index = ("AD,AE,AF,AG,AI,AL,AM,AN,AO,AQ,AR,AS,AT,AU,AW,AZ,BA,BB,BD,BE,BF," @@ -729,9 +729,13 @@ public final class Locale implements Serializable, Cloneable return false; Locale l = (Locale) obj; - return (language.equals(l.language) - && country.equals(l.country) - && variant.equals(l.variant)); + // ??? We might also want to add: + // hashCode() == l.hashCode() + // But this is a synchronized method. Is the overhead worth it? + // Measure this to make a decision. + return (language == l.language + && country == l.country + && variant == l.variant); } /**