* <ul>
* <li>Is not <code>null</code>.
* <li>Is an instance of <code>DateFormat</code>.
- * <li>Has the same calendar and numberFormat field values as this object.
+ * <li>Has the same numberFormat field value as this object.
* </ul>
*
* @param obj The object to test for equality against.
*/
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);
}
/**
*/
public int hashCode ()
{
- int hash = calendar.hashCode();
if (numberFormat != null)
- hash ^= numberFormat.hashCode();
- return hash;
+ return numberFormat.hashCode();
+ else
+ return 0;
}
/**
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()))
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,
// 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;
*/
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,"
*/
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,"
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);
}
/**