com.ibm.icu.text
Class ChineseDateFormat

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

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
static class ChineseDateFormat.Field
          The instances of this inner class are used as attribute keys and values in AttributedCharacterIterator that ChineseDateFormat.formatToCharacterIterator() method returns.
 
Field Summary
 
Fields inherited from class com.ibm.icu.text.DateFormat
ABBR_MONTH, ABBR_MONTH_DAY, ABBR_MONTH_WEEKDAY_DAY, ABBR_STANDALONE_MONTH, AM_PM_FIELD, calendar, DATE_FIELD, DAY, 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, HOUR_GENERIC_TZ, HOUR_MINUTE, HOUR_MINUTE_GENERIC_TZ, HOUR_MINUTE_SECOND, HOUR_MINUTE_TZ, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR_TZ, HOUR0_FIELD, HOUR1_FIELD, HOUR24_MINUTE, HOUR24_MINUTE_SECOND, JULIAN_DAY_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MILLISECONDS_IN_DAY_FIELD, MINUTE_FIELD, MINUTE_SECOND, MONTH, MONTH_DAY, MONTH_FIELD, MONTH_WEEKDAY_DAY, NONE, NUM_MONTH, NUM_MONTH_DAY, NUM_MONTH_WEEKDAY_DAY, numberFormat, QUARTER_FIELD, RELATIVE, RELATIVE_DEFAULT, RELATIVE_FULL, RELATIVE_LONG, RELATIVE_MEDIUM, RELATIVE_SHORT, SECOND_FIELD, SHORT, STANDALONE_DAY_FIELD, STANDALONE_MONTH, STANDALONE_MONTH_FIELD, STANDALONE_QUARTER_FIELD, TIMEZONE_FIELD, TIMEZONE_GENERIC_FIELD, TIMEZONE_RFC_FIELD, TIMEZONE_SPECIAL_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR, YEAR_ABBR_MONTH, YEAR_ABBR_MONTH_DAY, YEAR_ABBR_MONTH_WEEKDAY_DAY, YEAR_ABBR_QUARTER, YEAR_FIELD, YEAR_MONTH, YEAR_MONTH_DAY, YEAR_MONTH_WEEKDAY_DAY, YEAR_NUM_MONTH, YEAR_NUM_MONTH_DAY, YEAR_NUM_MONTH_WEEKDAY_DAY, YEAR_QUARTER, YEAR_WOY_FIELD
 
Constructor Summary
ChineseDateFormat(String pattern, Locale locale)
          Construct a ChineseDateFormat from a date format pattern and locale
ChineseDateFormat(String pattern, String override, ULocale locale)
          Construct a ChineseDateFormat from a date format pattern, numbering system override and locale
ChineseDateFormat(String pattern, ULocale locale)
          Construct a ChineseDateFormat from a date format pattern and locale
 
Method Summary
protected  DateFormat.Field patternCharToDateFormatField(char ch)
          Returns a DateFormat.Field constant associated with the specified format pattern character.
protected  void subFormat(StringBuffer buf, char ch, int count, int beginOffset, FieldPosition pos, Calendar cal)
          Deprecated. This API is ICU internal only.
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, formatToCharacterIterator, get2DigitYearStart, getDateFormatSymbols, getInstance, getNumberFormat, getSymbols, getTimeZoneFormat, hashCode, intervalFormatByAlgorithm, matchQuarterString, matchString, parse, set2DigitYearStart, setDateFormatSymbols, setNumberFormat, setTimeZoneFormat, 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, getPatternInstance, getPatternInstance, getPatternInstance, getPatternInstance, getPatternInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parse, parseObject, setCalendar, setLenient, setTimeZone
 
Methods inherited from class com.ibm.icu.text.UFormat
getLocale
 
Methods inherited from class java.text.Format
format, 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)
Construct a ChineseDateFormat from a date format pattern and locale

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

ChineseDateFormat

public ChineseDateFormat(String pattern,
                         String override,
                         ULocale locale)
Construct a ChineseDateFormat from a date format pattern, numbering system override and locale

Parameters:
pattern - the pattern
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.
locale - the locale
Status:
Stable ICU 4.2.
Method Detail

subFormat

protected void subFormat(StringBuffer buf,
                         char ch,
                         int count,
                         int beginOffset,
                         FieldPosition pos,
                         Calendar cal)
Deprecated. This API is ICU internal only.

Formats 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.

Overrides:
subFormat in class SimpleDateFormat
Status:
Internal. This API is ICU internal only.

subParse

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. 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.

patternCharToDateFormatField

protected DateFormat.Field patternCharToDateFormatField(char ch)
Returns a DateFormat.Field constant associated with the specified format pattern character.

Overrides:
patternCharToDateFormatField in class SimpleDateFormat
Parameters:
ch - The pattern character
Returns:
DateFormat.Field associated with the pattern character
Status:
Stable ICU 3.8.


Copyright (c) 2011 IBM Corporation and others.