com.ibm.icu.text
Class ChineseDateFormat
java.lang.Object
java.text.Format
com.ibm.icu.text.UFormat
com.ibm.icu.text.DateFormat
com.ibm.icu.text.SimpleDateFormat
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
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, STANDALONE_DAY_FIELD, STANDALONE_MONTH_FIELD, TIMEZONE_FIELD, TIMEZONE_GENERIC_FIELD, TIMEZONE_RFC_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD, YEAR_WOY_FIELD |
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, setNumberFormat, 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, setTimeZone |
ChineseDateFormat
public ChineseDateFormat(String pattern,
Locale locale)
- Construct a ChineseDateFormat from a date format pattern and locale
- Parameters:
pattern
- the patternlocale
- the locale
ChineseDateFormat
public ChineseDateFormat(String pattern,
ULocale locale)
- Construct a ChineseDateFormat from a date format pattern and locale
- Parameters:
pattern
- the patternlocale
- the locale
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
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.
Copyright (c) 2006 IBM Corporation and others.