* @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
* 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));
* 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);
* 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),
/**
* {@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) {
/**
* {@inheritDoc}
*
- * @stable ICU 3.8
+ * @deprecated ICU 50
*/
protected DateFormat.Field patternCharToDateFormatField(char ch) {
// no longer any field corresponding to pattern char 'l'
* 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 {
/**
* 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);
* @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);
* @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
/**
* {@inheritDoc}
*
- * @stable ICU 3.8
+ * @deprecated ICU 50
*/
///CLOVER:OFF
protected Object readResolve() throws InvalidObjectException {
* @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
/**
* 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));
/**
* 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));
/**
* 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);
* 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);
* 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);
// New API
/**
- * @stable ICU 2.0
+ * @deprecated ICU 50
*/
public String getLeapMonth(int leap) {
return isLeapMonth[leap];
/**
* {@inheritDoc}
- * @stable ICU 3.0
+ * @deprecated ICU 50
*/
protected void initializeData(ULocale loc, CalendarData calData) {
super.initializeData(loc, calData);
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;
* {@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
}
/**
- * 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);
}
/**
}
}
- 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(),
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(){