Hi,
This reworks the localization for Calendar and GregorianCalendar, moving
the week-data into gnu.java.locale.LocaleInformation and allowing us to
get rid of gnu.java.locale.Calendar*.java. The neccessary changes to
localegen have been posted to the cp-tools list. Once the regenerated
locale files are in place, I can commit this.
It fixes one of two related mauve tests. :)
(The remaining failure here is due to minimalDaysInFirstWeek not being
specified for some reason in the CLDR file for en_UK, and not due to
us.)
2005-04-06 Sven de Marothy <[EMAIL PROTECTED]>
* java/util/Calendar.java,
Move localization string for default calendar into Calendar.
(Calendar): Get locale info from LocaleInformation bundle.
* java/util/GregorianCalendar.java,
GregorianCutover is not localized.
(GregorianCalendar): Get locale info from LocaleInformation bundle.
Index: java/util/Calendar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.39
diff -u -r1.39 Calendar.java
--- java/util/Calendar.java 16 Feb 2005 12:36:21 -0000 1.39
+++ java/util/Calendar.java 6 Mar 2005 20:12:59 -0000
@@ -363,6 +363,14 @@
private TimeZone zone;
/**
+ * This is the default calendar class, that is returned on
+ * java.util.Calendar.getInstance().
+ * XXX - this isn't localized anywhere, is it?
+ * @see java.util.Calendar#getInstance()
+ */
+ private static final String calendarClassName = "java.util.GregorianCalendar";
+
+ /**
* Specifies if the date/time interpretation should be lenient.
* If the flag is set, a date such as "February 30, 1996" will be
* treated as the 29th day after the February 1. If this flag
@@ -416,7 +424,7 @@
/**
* 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.LocaleInformation";
/**
* get resource bundle:
@@ -448,12 +456,27 @@
{
this.zone = zone;
lenient = true;
+ String[] days = { "", "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
ResourceBundle rb = getBundle(locale);
+ String min = (String) rb.getObject("minNumberOfDaysInFirstWeek");
+ String first = (String) rb.getObject("firstDayOfWeek");
+ try
+ {
+ if (min != null)
+ minimalDaysInFirstWeek = Integer.parseInt(min);
+ }
+ catch (NumberFormatException ex)
+ {
+ minimalDaysInFirstWeek = 1;
+ }
+
+ firstDayOfWeek = 1;
+ if (first != null)
+ for (int i = 0; i < 8; i++)
+ if (days[i].equals(first))
+ firstDayOfWeek = i;
- firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue();
- minimalDaysInFirstWeek = ((Integer) rb.getObject("minimalDaysInFirstWeek"))
- .intValue();
clear();
}
@@ -513,15 +536,9 @@
{
if (calendarClass == null)
{
- ResourceBundle rb = getBundle(locale);
- String calendarClassName = rb.getString("calendarClass");
-
- if (calendarClassName != null)
- {
- calendarClass = Class.forName(calendarClassName);
- if (Calendar.class.isAssignableFrom(calendarClass))
- cache.put(locale, calendarClass);
- }
+ calendarClass = Class.forName(calendarClassName);
+ if (Calendar.class.isAssignableFrom(calendarClass))
+ cache.put(locale, calendarClass);
}
// GregorianCalendar is by far the most common case. Optimize by
Index: java/util/GregorianCalendar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.39
diff -u -r1.39 GregorianCalendar.java
--- java/util/GregorianCalendar.java 17 Feb 2005 18:59:55 -0000 1.39
+++ java/util/GregorianCalendar.java 6 Mar 2005 20:12:59 -0000
@@ -145,14 +145,19 @@
/**
* The point at which the Gregorian calendar rules were used.
- * This is locale dependent; the default for most catholic
- * countries is midnight (UTC) on October 5, 1582 (Julian),
+ * This may be changed by using setGregorianChange;
+ * The default is midnight (UTC) on October 5, 1582 (Julian),
* or October 15, 1582 (Gregorian).
*
* @serial the changeover point from the Julian calendar
* system to the Gregorian.
*/
- private long gregorianCutover;
+ private long gregorianCutover = (new Date((24 * 60 * 60 * 1000L) * (((1582 * (365 * 4
+ + 1)) / 4
+ + (java.util.Calendar.OCTOBER * (31
+ + 30 + 31 + 30 + 31) - 9) / 5 + 5)
+ - ((1970 * (365 * 4 + 1)) / 4 + 1
+ - 13)))).getTime();
/**
* For compatability with Sun's JDK.
@@ -160,11 +165,6 @@
static final long serialVersionUID = -8125100834729963327L;
/**
- * The name of the resource bundle. Used only by getBundle()
- */
- private static final String bundleName = "gnu.java.locale.Calendar";
-
- /**
* Days in the epoch. Relative Jan 1, year '0' which is not a leap year.
* (although there is no year zero, this does not matter.)
* This is consistent with the formula:
@@ -236,10 +236,6 @@
private GregorianCalendar(TimeZone zone, Locale locale, boolean unused)
{
super(zone, locale);
- ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale,
- ClassLoader
- .getSystemClassLoader());
- gregorianCutover = ((Date) rb.getObject("gregorianCutOver")).getTime();
}
/**
@@ -925,9 +921,7 @@
}
int maxDay = getActualMaximum(DAY_OF_MONTH);
if (fields[DAY_OF_MONTH] > maxDay)
- {
- fields[DAY_OF_MONTH] = maxDay;
- }
+ fields[DAY_OF_MONTH] = maxDay;
set(YEAR, fields[YEAR]);
set(MONTH, fields[MONTH]);
break;
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches