Commit 73c7dd50 by Michael Koch Committed by Michael Koch

DateFormat.java, [...]: New versions from classpath.

2003-06-21  Michael Koch  <konqueror@gmx.de>

	* java/text/DateFormat.java,
	java/text/SimpleDateFormat.java,
	java/util/Locale.java:
	New versions from classpath.

From-SVN: r68300
parent 5ee8128f
2003-06-21 Michael Koch <konqueror@gmx.de> 2003-06-21 Michael Koch <konqueror@gmx.de>
* java/text/DateFormat.java,
java/text/SimpleDateFormat.java,
java/util/Locale.java:
New versions from classpath.
2003-06-21 Michael Koch <konqueror@gmx.de>
* javax/swing/SpinnerModel.java: * javax/swing/SpinnerModel.java:
New file from classpath. New file from classpath.
* javax/swing/border/LineBorder.java, * javax/swing/border/LineBorder.java,
......
...@@ -101,7 +101,7 @@ public abstract class DateFormat extends Format implements Cloneable ...@@ -101,7 +101,7 @@ public abstract class DateFormat extends Format implements Cloneable
* <ul> * <ul>
* <li>Is not <code>null</code>. * <li>Is not <code>null</code>.
* <li>Is an instance of <code>DateFormat</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> * </ul>
* *
* @param obj The object to test for equality against. * @param obj The object to test for equality against.
...@@ -111,10 +111,12 @@ public abstract class DateFormat extends Format implements Cloneable ...@@ -111,10 +111,12 @@ public abstract class DateFormat extends Format implements Cloneable
*/ */
public boolean equals (Object obj) public boolean equals (Object obj)
{ {
if (! (obj instanceof DateFormat)) if (!(obj instanceof DateFormat))
return false; return false;
DateFormat d = (DateFormat) obj; 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 ...@@ -467,10 +469,10 @@ public abstract class DateFormat extends Format implements Cloneable
*/ */
public int hashCode () public int hashCode ()
{ {
int hash = calendar.hashCode();
if (numberFormat != null) if (numberFormat != null)
hash ^= numberFormat.hashCode(); return numberFormat.hashCode();
return hash; else
return 0;
} }
/** /**
......
...@@ -384,10 +384,10 @@ public class SimpleDateFormat extends DateFormat ...@@ -384,10 +384,10 @@ public class SimpleDateFormat extends DateFormat
SimpleDateFormat sdf = (SimpleDateFormat)o; SimpleDateFormat sdf = (SimpleDateFormat)o;
if (!toPattern().equals(sdf.toPattern())) if (defaultCentury != sdf.defaultCentury)
return false; return false;
if (!get2DigitYearStart().equals(sdf.get2DigitYearStart())) if (!toPattern().equals(sdf.toPattern()))
return false; return false;
if (!getDateFormatSymbols().equals(sdf.getDateFormatSymbols())) if (!getDateFormatSymbols().equals(sdf.getDateFormatSymbols()))
...@@ -396,6 +396,17 @@ public class SimpleDateFormat extends DateFormat ...@@ -396,6 +396,17 @@ public class SimpleDateFormat extends DateFormat
return true; 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, * Formats the date input according to the format string in use,
......
...@@ -231,9 +231,9 @@ public final class Locale implements Serializable, Cloneable ...@@ -231,9 +231,9 @@ public final class Locale implements Serializable, Cloneable
// default locale. // default locale.
if (defaultLocale != null) if (defaultLocale != null)
{ {
language = convertLanguage(language); language = convertLanguage(language).intern();
country = country.toUpperCase(); country = country.toUpperCase().intern();
variant = variant.toUpperCase(); variant = variant.toUpperCase().intern();
} }
this.language = language; this.language = language;
this.country = country; this.country = country;
...@@ -436,7 +436,7 @@ public final class Locale implements Serializable, Cloneable ...@@ -436,7 +436,7 @@ public final class Locale implements Serializable, Cloneable
*/ */
public String getISO3Language() public String getISO3Language()
{ {
if ("".equals(language)) if (language == "")
return ""; return "";
int index int index
= ("aa,ab,af,am,ar,as,ay,az,ba,be,bg,bh,bi,bn,bo,br,ca,co,cs,cy,da," = ("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 ...@@ -472,7 +472,7 @@ public final class Locale implements Serializable, Cloneable
*/ */
public String getISO3Country() public String getISO3Country()
{ {
if ("".equals(country)) if (country == "")
return ""; return "";
int index int index
= ("AD,AE,AF,AG,AI,AL,AM,AN,AO,AQ,AR,AS,AT,AU,AW,AZ,BA,BB,BD,BE,BF," = ("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 ...@@ -729,9 +729,13 @@ public final class Locale implements Serializable, Cloneable
return false; return false;
Locale l = (Locale) obj; Locale l = (Locale) obj;
return (language.equals(l.language) // ??? We might also want to add:
&& country.equals(l.country) // hashCode() == l.hashCode()
&& variant.equals(l.variant)); // 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);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment