]> granicus.if.org Git - icu/commitdiff
ICU-9140 Deprecate ChineseDateFormat/ChineseDateFormatSymbols. Changed DateFormat...
authorYoshito Umaoka <y.umaoka@gmail.com>
Thu, 14 Jun 2012 20:14:10 +0000 (20:14 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Thu, 14 Jun 2012 20:14:10 +0000 (20:14 +0000)
X-SVN-Rev: 31953

icu4j/main/classes/core/src/com/ibm/icu/text/ChineseDateFormat.java
icu4j/main/classes/core/src/com/ibm/icu/text/ChineseDateFormatSymbols.java
icu4j/main/classes/core/src/com/ibm/icu/util/ChineseCalendar.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/ChineseTest.java

index 91a44274686892d4d6ffec3f2266bb0002ede943..75ad5d8a1170a44ab4dbf12fa3381b0f1fd4574b 100644 (file)
@@ -40,7 +40,7 @@ import com.ibm.icu.util.ULocale;
  * @see com.ibm.icu.util.ChineseCalendar
  * @see ChineseDateFormatSymbols
  * @author Alan Liu
- * @stable ICU 2.0
+ * @deprecated ICU 50 Use SimpleDateFormat instead.
  */
 public class ChineseDateFormat extends SimpleDateFormat {
     // Generated by serialver from JDK 1.4.1_01
@@ -52,7 +52,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
      * Construct a ChineseDateFormat from a date format pattern and locale
      * @param pattern the pattern
      * @param locale the locale
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
    public ChineseDateFormat(String pattern, Locale locale) {
        this(pattern, ULocale.forLocale(locale));
@@ -62,7 +62,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
      * Construct a ChineseDateFormat from a date format pattern and locale
      * @param pattern the pattern
      * @param locale the locale
-     * @stable ICU 3.2
+     * @deprecated ICU 50
      */
    public ChineseDateFormat(String pattern, ULocale locale) {
        this(pattern, null, locale);
@@ -79,7 +79,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
      *         string by separating them with a semi-colon. For example, the override string "m=thai;y=deva" would format using
      *         Thai digits for the month and Devanagari digits for the year.
      * @param locale the locale
-     * @stable ICU 4.2
+     * @deprecated ICU 50
      */
    public ChineseDateFormat(String pattern, String override, ULocale locale) {
        super(pattern, new ChineseDateFormatSymbols(locale), 
@@ -135,7 +135,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
     /**
      * {@inheritDoc}
      * 
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
     protected int subParse(String text, int start, char ch, int count, boolean obeyCount, boolean allowNegative,
             boolean[] ambiguousYear, Calendar cal) {
@@ -151,7 +151,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
     /**
      * {@inheritDoc}
      * 
-     * @stable ICU 3.8
+     * @deprecated ICU 50
      */
     protected DateFormat.Field patternCharToDateFormatField(char ch) {
         // no longer any field corresponding to pattern char 'l'
@@ -166,7 +166,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
      * There is no public constructor to this class, the only instances are the
      * constants defined here.
      * <p>
-     * @stable ICU 3.8
+     * @deprecated ICU 50
      */
     public static class Field extends DateFormat.Field {
 
@@ -174,7 +174,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
 
         /**
          * Constant identifying the leap month marker.
-         * @stable ICU 3.8
+         * @deprecated ICU 50 This field is only used by the deprecated ChineseDateFormat class.
          */
         public static final Field IS_LEAP_MONTH = new Field("is leap month", ChineseCalendar.IS_LEAP_MONTH);
 
@@ -187,7 +187,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
          * @param name          Name of the attribute
          * @param calendarField <code>Calendar</code> field constant
          * 
-         * @stable ICU 3.8
+         * @deprecated ICU 50
          */
         protected Field(String name, int calendarField) {
             super(name, calendarField);
@@ -204,7 +204,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
          * @throws IllegalArgumentException if <code>calendarField</code> is not
          * a valid <code>Calendar</code> field constant.
          * 
-         * @stable ICU 3.8
+         * @deprecated ICU 50
          */
         public static DateFormat.Field ofCalendarField(int calendarField) {
             // Should we remove the following, since there is no longer a specific
@@ -218,7 +218,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
         /**
          * {@inheritDoc}
          * 
-         * @stable ICU 3.8
+         * @deprecated ICU 50
          */
         ///CLOVER:OFF
         protected Object readResolve() throws InvalidObjectException {
index 7026d552620f0ea6b520a941d07e5fb687972cb4..a106d4fe0f599be8dc86d2df4456085e136be96f 100644 (file)
@@ -22,7 +22,7 @@ import com.ibm.icu.util.ULocale.Category;
  * @see ChineseDateFormat
  * @see com.ibm.icu.util.ChineseCalendar
  * @author Alan Liu
- * @stable ICU 2.0
+ * @deprecated ICU 50 
  */
 public class ChineseDateFormatSymbols extends DateFormatSymbols {
     // Generated by serialver from JDK 1.4.1_01
@@ -37,7 +37,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
     /**
      * Construct a ChineseDateFormatSymbols for the default <code>FORMAT</code> locale.
      * @see Category#FORMAT
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
     public ChineseDateFormatSymbols() {
         this(ULocale.getDefault(Category.FORMAT));
@@ -46,7 +46,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
     /**
      * Construct a ChineseDateFormatSymbols for the provided locale.
      * @param locale the locale
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
     public ChineseDateFormatSymbols(Locale locale) {
         super(ChineseCalendar.class, ULocale.forLocale(locale));
@@ -55,7 +55,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
     /**
      * Construct a ChineseDateFormatSymbols for the provided locale.
      * @param locale the locale
-     * @stable ICU 3.2
+     * @deprecated ICU 50
      */
     public ChineseDateFormatSymbols(ULocale locale) {
         super(ChineseCalendar.class, locale);
@@ -65,7 +65,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
      * Construct a ChineseDateFormatSymbols for the provided calendar and locale.
      * @param cal the Calendar
      * @param locale the locale
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
     public ChineseDateFormatSymbols(Calendar cal, Locale locale) {
         super(cal==null?null:cal.getClass(), locale);
@@ -75,7 +75,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
      * Construct a ChineseDateFormatSymbols for the provided calendar and locale.
      * @param cal the Calendar
      * @param locale the locale
-     * @stable ICU 3.2
+     * @deprecated ICU 50
      */
     public ChineseDateFormatSymbols(Calendar cal, ULocale locale) {
         super(cal == null ? null : cal.getClass(), locale);
@@ -83,7 +83,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
 
     // New API
     /**
-     * @stable ICU 2.0
+     * @deprecated ICU 50
      */
     public String getLeapMonth(int leap) {
         return isLeapMonth[leap];
@@ -91,7 +91,7 @@ public class ChineseDateFormatSymbols extends DateFormatSymbols {
 
     /**
      * {@inheritDoc}
-     * @stable ICU 3.0
+     * @deprecated ICU 50
      */
     protected void initializeData(ULocale loc, CalendarData calData) {
         super.initializeData(loc, calData);
index 3781a7af76c9a51bebec3db753c0fed255a8cd1e..4a785739c5ba12710645dbfb8d2909e57862bd9b 100644 (file)
@@ -13,7 +13,6 @@ import java.util.Locale;
 
 import com.ibm.icu.impl.CalendarAstronomer;
 import com.ibm.icu.impl.CalendarCache;
-import com.ibm.icu.text.ChineseDateFormat;
 import com.ibm.icu.text.DateFormat;
 import com.ibm.icu.util.ULocale.Category;
 
@@ -77,7 +76,6 @@ import com.ibm.icu.util.ULocale.Category;
  * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code>
  * with the tag <code>"@calendar=chinese"</code>.</p>
  *
- * @see com.ibm.icu.text.ChineseDateFormat
  * @see com.ibm.icu.util.Calendar
  * @author Alan Liu
  * @stable ICU 2.8
@@ -478,23 +476,18 @@ public class ChineseCalendar extends Calendar {
     }
 
     /**
-     * Framework method to create a calendar-specific DateFormat object
-     * using the the given pattern.  This method is responsible for
-     * creating the calendar- specific DateFormat and DateFormatSymbols
-     * objects as needed.
-     * @param pattern The date formatting pattern
-     * @param override The override string.  A numbering system override string can take one of the following forms:
-     *     1). If just a numbering system name is specified, it applies to all numeric fields in the date format pattern.
-     *     2). To specify an alternate numbering system on a field by field basis, use the field letters from the pattern
-     *         followed by an = sign, followed by the numbering system name.  For example, to specify that just the year
-     *         be formatted using Hebrew digits, use the override "y=hebr".  Multiple overrides can be specified in a single
-     *         string by separating them with a semi-colon. For example, the override string "m=thai;y=deva" would format using
-     *         Thai digits for the month and Devanagari digits for the year.
-     * @param locale The locale
+     * {@inheritDoc}
+     * 
      * @stable ICU 4.2
      */
     protected DateFormat handleGetDateFormat(String pattern, String override, ULocale locale) {
-        return new ChineseDateFormat(pattern, override, locale);
+        // Note: ICU 50 or later versions no longer use ChineseDateFormat.
+        // The super class's handleGetDateFormat will create an instance of
+        // SimpleDateFormat which supports Chinese calendar date formatting
+        // since ICU 49.
+
+        //return new ChineseDateFormat(pattern, override, locale);
+        return super.handleGetDateFormat(pattern, override, locale);
     }
 
     /**
index 2dff1a7472e1d8fab8f60a6ebead1c43541ec483..d0d73f0b22bf98e2d7675dea23e718f4b6434397 100644 (file)
@@ -620,21 +620,26 @@ public class ChineseTest extends CalendarTest {
             }
         }
 
-        ChineseCalendar cal = new ChineseCalendar();
-        DateFormat format = DateFormat.getInstance(cal);
-        if(!(format instanceof ChineseDateFormat)){
-            errln("DateFormat.getInstance("+cal+") did not return a ChineseDateFormat");
-        }
-        ChineseDateFormat fmt = (ChineseDateFormat)format;
-        fmt.applyPattern("llyyll");
-        Date time = getDate(2100, Calendar.JANUARY, 1);
-        String str = fmt.format(time);
-        try {
-            Date e = fmt.parse(str);
-            logln("chinese calendar time: " + time + " result: " + str + " --> " + e);
-        } catch (java.text.ParseException ex) {
-            logln(ex.getMessage()); // chinese calendar can't parse this, no error for now
-        }
+        // Note: ICU 50 or later versions, DateFormat.getInstance(ChineseCalendar) no longer
+        // returns an instance of ChineseDateFormat. Chinese calendar formatting support was
+        // changed and integrated into SimpleDateFormat since ICU 49. Also, ChineseDateFormat
+        // specific pattern letter "l" is no longer used by the new implementation.
+
+//        ChineseCalendar cal = new ChineseCalendar();
+//        DateFormat format = DateFormat.getInstance(cal);
+//        if(!(format instanceof ChineseDateFormat)){
+//            errln("DateFormat.getInstance("+cal+") did not return a ChineseDateFormat");
+//        }
+//        ChineseDateFormat fmt = (ChineseDateFormat)format;
+//        fmt.applyPattern("llyyll");
+//        Date time = getDate(2100, Calendar.JANUARY, 1);
+//        String str = fmt.format(time);
+//        try {
+//            Date e = fmt.parse(str);
+//            logln("chinese calendar time: " + time + " result: " + str + " --> " + e);
+//        } catch (java.text.ParseException ex) {
+//            logln(ex.getMessage()); // chinese calendar can't parse this, no error for now
+//        }
 
         //new ChineseCalendar(TimeZone,ULocale)
         ChineseCalendar ccal2 = new ChineseCalendar(TimeZone.getDefault(),
@@ -642,10 +647,10 @@ public class ChineseTest extends CalendarTest {
         if(ccal2==null){
             errln("could not create ChineseCalendar with TimeZone ULocale");
         } else {
-            fmt = (ChineseDateFormat)DateFormat.getDateInstance(ccal2, DateFormat.DEFAULT, ULocale.CHINA);
-            time = getDate(2001, Calendar.MAY, 23);
-            str = fmt.format(time);
-            logln("Chinese calendar time: " + time + " result: " + str);
+            DateFormat fmt2 = DateFormat.getDateInstance(ccal2, DateFormat.DEFAULT, ULocale.CHINA);
+            Date time2 = getDate(2001, Calendar.MAY, 23);
+            String str2 = fmt2.format(time2);
+            logln("Chinese calendar time: " + time2 + " result: " + str2);
         }
     }
     public void TestScratch(){