com.ibm.icu.text
Class ChineseDateFormat

java.lang.Object
  extended byjava.text.Format
      extended bycom.ibm.icu.text.UFormat
          extended bycom.ibm.icu.text.DateFormat
              extended bycom.ibm.icu.text.SimpleDateFormat
                  extended bycom.ibm.icu.text.ChineseDateFormat
All Implemented Interfaces:
Cloneable, Serializable

public class ChineseDateFormat
extends SimpleDateFormat

A concrete DateFormat for ChineseCalendar. This class handles a ChineseCalendar-specific field, ChineseCalendar.IS_LEAP_MONTH. It also redefines the handling of two fields, ERA and YEAR. The former is displayed numerically, instead of symbolically, since it is the numeric cycle number in ChineseCalendar. The latter is numeric, as before, but has no special 2-digit Y2K behavior.

With regard to ChineseCalendar.IS_LEAP_MONTH, this class handles parsing specially. If no string symbol is found at all, this is taken as equivalent to an IS_LEAP_MONTH value of zero. This allows formats to display a special string (e.g., "*") for leap months, but no string for normal months.

Summary of field changes vs. SimpleDateFormat:

 Symbol   Meaning                 Presentation        Example
 ------   -------                 ------------        -------
 G        cycle                   (Number)            78
 y        year of cycle (1..60)   (Number)            17
 l        is leap month           (Text)              4637
 

Author:
Alan Liu
See Also:
ChineseCalendar, ChineseDateFormatSymbols, Serialized Form
Status:
Stable ICU 2.0.

Nested Class Summary
 
Nested classes inherited from class java.text.Format
Format.Field
 
Field Summary
 
Fields inherited from class com.ibm.icu.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, DOW_LOCAL_FIELD, ERA_FIELD, EXTENDED_YEAR_FIELD, FIELD_COUNT, FRACTIONAL_SECOND_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, JULIAN_DAY_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MILLISECONDS_IN_DAY_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, TIMEZONE_RFC_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD, YEAR_WOY_FIELD
 
Constructor Summary
ChineseDateFormat(String pattern, Locale locale)
          Construct a ChineseDateFormat from a date format pattern and locale
ChineseDateFormat(String pattern, ULocale locale)
          Deprecated. This is a draft API and might change in a future release of ICU.
 
Method Summary
protected  void subFormat(StringBuffer buf, char ch, int count, int beginOffset, FieldPosition pos, Calendar cal)
          Format a single field; useFastFormat variant.
protected  int subParse(String text, int start, char ch, int count, boolean obeyCount, boolean allowNegative, boolean[] ambiguousYear, Calendar cal)
          Protected method that converts one field of the input string into a numeric field value in cal.
 
Methods inherited from class com.ibm.icu.text.SimpleDateFormat
applyLocalizedPattern, applyPattern, clone, equals, format, get2DigitYearStart, getDateFormatSymbols, getSymbols, hashCode, matchString, parse, set2DigitYearStart, setDateFormatSymbols, subFormat, toLocalizedPattern, toPattern, zeroPaddingNumber, zeroPaddingNumber
 
Methods inherited from class com.ibm.icu.text.DateFormat
format, format, format, getAvailableLocales, getAvailableULocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getInstance, getInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
 
Methods inherited from class com.ibm.icu.text.UFormat
getLocale
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChineseDateFormat

public ChineseDateFormat(String pattern,
                         Locale locale)
Construct a ChineseDateFormat from a date format pattern and locale

Parameters:
pattern - the pattern
locale - the locale
Status:
Stable ICU 2.0.

ChineseDateFormat

public ChineseDateFormat(String pattern,
                         ULocale locale)
Deprecated. This is a draft API and might change in a future release of ICU.

Construct a ChineseDateFormat from a date format pattern and locale

Parameters:
pattern - the pattern
locale - the locale
Status:
Draft ICU 3.2.
Status:
Deprecated in This is a draft API and might change in a future release of ICU..
Method Detail

subFormat

protected void subFormat(StringBuffer buf,
                         char ch,
                         int count,
                         int beginOffset,
                         FieldPosition pos,
                         Calendar cal)
Description copied from class: SimpleDateFormat
Format a single field; useFastFormat variant. Reuses a StringBuffer for results instead of creating a String on the heap for each call. NOTE We don't really need the beginOffset parameter, EXCEPT for the need to support the slow subFormat variant (above) which has to pass it in to us. TODO make this API public

Overrides:
subFormat in class SimpleDateFormat
Status:
Internal. This API is Internal Only and can change at any time.

subParse

protected int subParse(String text,
                       int start,
                       char ch,
                       int count,
                       boolean obeyCount,
                       boolean allowNegative,
                       boolean[] ambiguousYear,
                       Calendar cal)
Description copied from class: SimpleDateFormat
Protected method that converts one field of the input string into a numeric field value in cal. Returns -start (for ParsePosition) if failed. Subclasses may override this method to modify or add parsing capabilities.

Overrides:
subParse in class SimpleDateFormat
Parameters:
text - the time text to be parsed.
start - where to start parsing.
ch - the pattern character for the date field text to be parsed.
count - the count of a pattern character.
obeyCount - if true, then the next field directly abuts this one, and we should use the count to know when to stop parsing.
ambiguousYear - return parameter; upon return, if ambiguousYear[0] is true, then a two-digit year was parsed and may need to be readjusted.
Returns:
the new start position if matching succeeded; a negative number indicating matching failure, otherwise. As a side effect, set the appropriate field of cal with the parsed value.
Status:
Stable ICU 2.0.


Copyright (c) 2004 IBM Corporation and others.