com.ibm.text
Class ChineseDateFormat

java.lang.Object
  |
  +--java.text.Format
        |
        +--com.ibm.text.DateFormat
              |
              +--com.ibm.text.SimpleDateFormat
                    |
                    +--com.ibm.text.ChineseDateFormat
All Implemented Interfaces:
java.lang.Cloneable, java.io.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

Fields inherited from class com.ibm.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
 
Constructor Summary
ChineseDateFormat(java.lang.String pattern, java.util.Locale locale)
           
 
Method Summary
protected  java.lang.String subFormat(char ch, int count, int beginOffset, java.text.FieldPosition pos, DateFormatSymbols formatData)
          Format a single field, given its pattern character.
protected  int subParse(java.lang.String text, int start, char ch, int count, boolean obeyCount, boolean[] ambiguousYear)
          Protected method that converts one field of the input string into a numeric field value in calendar.
 
Methods inherited from class com.ibm.text.SimpleDateFormat
applyLocalizedPattern, applyPattern, clone, equals, format, get2DigitYearStart, getDateFormatSymbols, getSymbols, hashCode, matchString, parse, set2DigitYearStart, setDateFormatSymbols, toLocalizedPattern, toPattern, zeroPaddingNumber
 
Methods inherited from class com.ibm.text.DateFormat
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
 
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(java.lang.String pattern,
                         java.util.Locale locale)
Method Detail

subFormat

protected java.lang.String subFormat(char ch,
                                     int count,
                                     int beginOffset,
                                     java.text.FieldPosition pos,
                                     DateFormatSymbols formatData)
Description copied from class: SimpleDateFormat
Format a single field, given its pattern character. Subclasses may override this method in order to modify or add formatting capabilities.
Overrides:
subFormat in class SimpleDateFormat
Following copied from class: com.ibm.text.SimpleDateFormat
Parameters:
ch - the pattern character
count - the number of times ch is repeated in the pattern
beginOffset - the offset of the output string at the start of this field; used to set pos when appropriate
pos - receives the position of a field, when appropriate
formatData - the symbols for this formatter

subParse

protected int subParse(java.lang.String text,
                       int start,
                       char ch,
                       int count,
                       boolean obeyCount,
                       boolean[] ambiguousYear)
Description copied from class: SimpleDateFormat
Protected method that converts one field of the input string into a numeric field value in calendar. Returns -start (for ParsePosition) if failed. Subclasses may override this method to modify or add parsing capabilities.
Overrides:
subParse in class SimpleDateFormat
Following copied from class: com.ibm.text.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 calendar with the parsed value.


Copyright (c) 2001 IBM Corporation and others.