From 481973c60bf23391748f044e72521f775e3d9c8a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 21 May 2004 21:30:03 +0000 Subject: [PATCH] ICU-3301 move data from J to C format X-SVN-Rev: 15474 --- .../com/ibm/icu/util/BuddhistCalendar.java | 9 +++++ icu4j/src/com/ibm/icu/util/Calendar.java | 39 +++++++++++-------- .../src/com/ibm/icu/util/ChineseCalendar.java | 8 ++++ .../com/ibm/icu/util/GregorianCalendar.java | 11 +++++- .../src/com/ibm/icu/util/HebrewCalendar.java | 11 ++++++ .../src/com/ibm/icu/util/IslamicCalendar.java | 9 +++++ .../com/ibm/icu/util/JapaneseCalendar.java | 9 +++++ 7 files changed, 78 insertions(+), 18 deletions(-) diff --git a/icu4j/src/com/ibm/icu/util/BuddhistCalendar.java b/icu4j/src/com/ibm/icu/util/BuddhistCalendar.java index 6ac132e128..a0ecc1a61b 100755 --- a/icu4j/src/com/ibm/icu/util/BuddhistCalendar.java +++ b/icu4j/src/com/ibm/icu/util/BuddhistCalendar.java @@ -200,6 +200,15 @@ public class BuddhistCalendar extends GregorianCalendar { } return super.handleGetLimit(field, limitType); } + + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "buddhist"; + } /* private static CalendarFactory factory; diff --git a/icu4j/src/com/ibm/icu/util/Calendar.java b/icu4j/src/com/ibm/icu/util/Calendar.java index 6a4f2bdf61..bd0fdb94ed 100755 --- a/icu4j/src/com/ibm/icu/util/Calendar.java +++ b/icu4j/src/com/ibm/icu/util/Calendar.java @@ -10,6 +10,7 @@ import com.ibm.icu.impl.ICUResourceBundle; import com.ibm.icu.impl.ICUService.Factory; import com.ibm.icu.impl.ICULocaleService; import com.ibm.icu.impl.ICULocaleService.LocaleKeyFactory; +import com.ibm.icu.impl.CalendarData; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.DateFormatSymbols; import com.ibm.icu.text.SimpleDateFormat; @@ -2857,13 +2858,10 @@ public abstract class Calendar implements Serializable, Cloneable { // See if there are any custom resources for this calendar // If not, just use the default DateFormat DateFormat result = null; - - ResourceBundle bundle = DateFormatSymbols.getDateFormatBundle(cal, loc); - - if (bundle != null) { - + try { - String[] patterns = bundle.getStringArray("DateTimePatterns"); + CalendarData calData = new CalendarData(new ULocale(loc), cal.getType()); + String[] patterns = calData.get("DateTimePatterns").getStringArray(); String pattern = null; if ((timeStyle >= 0) && (dateStyle >= 0)) { @@ -2887,9 +2885,6 @@ public abstract class Calendar implements Serializable, Cloneable { DateFormatSymbols symbols = new DateFormatSymbols(cal, loc); ((SimpleDateFormat) result).setDateFormatSymbols(symbols); // aliu } - } else { - result = SimpleDateFormat.getDateTimeInstance(dateStyle, timeStyle, loc); - } result.setCalendar(cal); return result; } @@ -3691,15 +3686,15 @@ public abstract class Calendar implements Serializable, Cloneable { WeekData data = (WeekData) cachedLocaleData.get(locale); if (data == null) { /* cache miss */ - ICUResourceBundle dateRes = (ICUResourceBundle)UResourceBundle.getBundleInstance(UResourceBundle.ICU_BASE_NAME,locale); - int[] dateTimeElements = dateRes.get("DateTimeElements").getIntVector(); - String[] weekend = UResourceBundle.getBundleInstance("CalendarData", locale).getStringArray("Weekend"); + CalendarData calData = new CalendarData(new ULocale(locale), getType()); + int[] dateTimeElements = calData.get("DateTimeElements").getIntVector(); + int[] weekend = calData.get("weekend").getIntVector(); data = new WeekData(dateTimeElements[0],dateTimeElements[1], - Integer.parseInt(weekend[0]), - Integer.parseInt(weekend[1]), - Integer.parseInt(weekend[2]), - Integer.parseInt(weekend[3]), - dateRes.getULocale()); + weekend[0], + weekend[1], + weekend[2], + weekend[3], + calData.getULocale()); /* cache update */ cachedLocaleData.put(locale, data); } @@ -4890,6 +4885,16 @@ public abstract class Calendar implements Serializable, Cloneable { return time; } + /** + * Return the current Calendar type. + * Note, in 3.0 this function will return 'gregorian' in Calendar to emulate legacy behavior + * @return type of calendar (gregorian, etc) + * @internal ICU 3.0 + */ + public String getType() { + return "gregorian"; + } + // -------- BEGIN ULocale boilerplate -------- /** diff --git a/icu4j/src/com/ibm/icu/util/ChineseCalendar.java b/icu4j/src/com/ibm/icu/util/ChineseCalendar.java index 090cb3b294..26c621806a 100755 --- a/icu4j/src/com/ibm/icu/util/ChineseCalendar.java +++ b/icu4j/src/com/ibm/icu/util/ChineseCalendar.java @@ -798,6 +798,14 @@ public class ChineseCalendar extends Calendar { return julianDay - 1; } + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "chinese"; + } /* private static CalendarFactory factory; diff --git a/icu4j/src/com/ibm/icu/util/GregorianCalendar.java b/icu4j/src/com/ibm/icu/util/GregorianCalendar.java index 0abd6fb8b0..1f90b5e189 100755 --- a/icu4j/src/com/ibm/icu/util/GregorianCalendar.java +++ b/icu4j/src/com/ibm/icu/util/GregorianCalendar.java @@ -1,5 +1,5 @@ /* -* Copyright (C) 1996-2003, International Business Machines +* Copyright (C) 1996-2004, International Business Machines * Corporation and others. All Rights Reserved. */ package com.ibm.icu.util; @@ -844,6 +844,15 @@ public class GregorianCalendar extends Calendar { return julianDay; } + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "gregorian"; + } + /* private static CalendarFactory factory; public static CalendarFactory factory() { diff --git a/icu4j/src/com/ibm/icu/util/HebrewCalendar.java b/icu4j/src/com/ibm/icu/util/HebrewCalendar.java index 91925c74be..e3579ba362 100755 --- a/icu4j/src/com/ibm/icu/util/HebrewCalendar.java +++ b/icu4j/src/com/ibm/icu/util/HebrewCalendar.java @@ -802,6 +802,17 @@ public class HebrewCalendar extends Calendar { return (int) (day + 347997); } + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "hebrew"; + } + + + /* private static CalendarFactory factory; public static CalendarFactory factory() { diff --git a/icu4j/src/com/ibm/icu/util/IslamicCalendar.java b/icu4j/src/com/ibm/icu/util/IslamicCalendar.java index ef3c1f3b37..404153943e 100755 --- a/icu4j/src/com/ibm/icu/util/IslamicCalendar.java +++ b/icu4j/src/com/ibm/icu/util/IslamicCalendar.java @@ -605,6 +605,15 @@ public class IslamicCalendar extends Calendar { internalSet(DAY_OF_YEAR, dayOfYear); } + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "islamic"; + } + /* private static CalendarFactory factory; public static CalendarFactory factory() { diff --git a/icu4j/src/com/ibm/icu/util/JapaneseCalendar.java b/icu4j/src/com/ibm/icu/util/JapaneseCalendar.java index 41e4f45414..defefb4bfa 100755 --- a/icu4j/src/com/ibm/icu/util/JapaneseCalendar.java +++ b/icu4j/src/com/ibm/icu/util/JapaneseCalendar.java @@ -561,6 +561,15 @@ public class JapaneseCalendar extends GregorianCalendar { } } + /** + * Return the current Calendar type. + * @return type of calendar (gregorian, etc.) + * @internal ICU 3.0 + */ + public String getType() { + return "japanese"; + } + /* private static CalendarFactory factory; public static CalendarFactory factory() {