TimeZone.java: Initialize lazily.

2003-09-18  Ingo Proetel  <proetel@aicas.com>

	* java/util/TimeZone.java: Initialize lazily.
	* java/util/Locale.java (readManifest): Fix check for country.
	* java/util/GregorianCalendar.java: Make use of ResourceBundle better
	traceable
	* java/util/Calendar.java: Make use of ResourceBundle better
	traceable.

From-SVN: r71509
This commit is contained in:
Ingo Proetel 2003-09-18 06:34:00 +00:00 committed by Michael Koch
parent fc08ad2815
commit 1ea8e73b80
5 changed files with 736 additions and 694 deletions

View File

@ -1,3 +1,12 @@
2003-09-18 Ingo Proetel <proetel@aicas.com>
* java/util/TimeZone.java: Initialize lazily.
* java/util/Locale.java (readManifest): Fix check for country.
* java/util/GregorianCalendar.java: Make use of ResourceBundle better
traceable
* java/util/Calendar.java: Make use of ResourceBundle better
traceable.
2003-09-18 Jeroen Frijters <jeroen@frijters.net> 2003-09-18 Jeroen Frijters <jeroen@frijters.net>
* java/sql/Timestamp.java * java/sql/Timestamp.java

View File

@ -361,10 +361,20 @@ public abstract class Calendar implements Serializable, Cloneable
static final long serialVersionUID = -1807547505821590642L; static final long serialVersionUID = -1807547505821590642L;
/** /**
* The name of the resource bundle. * The name of the resource bundle. Used only by getBundle()
*/ */
private static final String bundleName = "gnu.java.locale.Calendar"; private static final String bundleName = "gnu.java.locale.Calendar";
/**
* get resource bundle:
* The resources should be loaded via this method only. Iff an application
* uses this method, the resourcebundle is required.
*/
private static ResourceBundle getBundle(Locale locale)
{
return ResourceBundle.getBundle(bundleName, locale);
}
/** /**
* Constructs a new Calendar with the default time zone and the default * Constructs a new Calendar with the default time zone and the default
* locale. * locale.
@ -385,7 +395,7 @@ public abstract class Calendar implements Serializable, Cloneable
this.zone = zone; this.zone = zone;
lenient = true; lenient = true;
ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale); ResourceBundle rb = getBundle(locale);
firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue(); firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue();
minimalDaysInFirstWeek = minimalDaysInFirstWeek =
@ -430,7 +440,7 @@ public abstract class Calendar implements Serializable, Cloneable
public static synchronized Calendar getInstance(TimeZone zone, Locale locale) public static synchronized Calendar getInstance(TimeZone zone, Locale locale)
{ {
String calendarClassName = null; String calendarClassName = null;
ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale); ResourceBundle rb = getBundle(locale);
calendarClassName = rb.getString("calendarClass"); calendarClassName = rb.getString("calendarClass");
if (calendarClassName != null) if (calendarClassName != null)
{ {
@ -461,8 +471,7 @@ public abstract class Calendar implements Serializable, Cloneable
*/ */
public static synchronized Locale[] getAvailableLocales() public static synchronized Locale[] getAvailableLocales()
{ {
ResourceBundle rb = ResourceBundle.getBundle(bundleName, ResourceBundle rb = getBundle(new Locale("", ""));
new Locale("", ""));
return (Locale[]) rb.getObject("availableLocales"); return (Locale[]) rb.getObject("availableLocales");
} }

View File

@ -78,10 +78,20 @@ public class GregorianCalendar extends Calendar
static final long serialVersionUID = -8125100834729963327L; static final long serialVersionUID = -8125100834729963327L;
/** /**
* The name of the resource bundle. * The name of the resource bundle. Used only by getBundle()
*/ */
private static final String bundleName = "gnu.java.locale.Calendar"; private static final String bundleName = "gnu.java.locale.Calendar";
/**
* get resource bundle:
* The resources should be loaded via this method only. Iff an application
* uses this method, the resourcebundle is required. --Fridi.
*/
private static ResourceBundle getBundle(Locale locale)
{
return ResourceBundle.getBundle(bundleName, locale);
}
/** /**
* Constructs a new GregorianCalender representing the current * Constructs a new GregorianCalender representing the current
* time, using the default time zone and the default locale. * time, using the default time zone and the default locale.
@ -120,7 +130,7 @@ public class GregorianCalendar extends Calendar
public GregorianCalendar(TimeZone zone, Locale locale) public GregorianCalendar(TimeZone zone, Locale locale)
{ {
super(zone, locale); super(zone, locale);
ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale); ResourceBundle rb = getBundle(locale);
gregorianCutover = ((Date) rb.getObject("gregorianCutOver")).getTime(); gregorianCutover = ((Date) rb.getObject("gregorianCutOver")).getTime();
setTimeInMillis(System.currentTimeMillis()); setTimeInMillis(System.currentTimeMillis());
} }

View File

@ -489,7 +489,7 @@ public final class Locale implements Serializable, Cloneable
+ "WS,YE,YT,YU,ZA,ZM,ZR,ZW") + "WS,YE,YT,YU,ZA,ZM,ZR,ZW")
.indexOf(country); .indexOf(country);
if (index % 3 != 0 || language.length() != 2) if (index % 3 != 0 || country.length() != 2)
throw new MissingResourceException throw new MissingResourceException
("Can't find ISO3 country for " + country, ("Can't find ISO3 country for " + country,
"java.util.Locale", country); "java.util.Locale", country);

File diff suppressed because it is too large Load Diff