Home | History | Annotate | Download | only in unicode
      1 /*
      2 * Copyright (C) 1997-2012, International Business Machines Corporation and
      3 * others. All Rights Reserved.
      4 *******************************************************************************
      5 *
      6 * File SMPDTFMT.H
      7 *
      8 * Modification History:
      9 *
     10 *   Date        Name        Description
     11 *   02/19/97    aliu        Converted from java.
     12 *   07/09/97    helena      Make ParsePosition into a class.
     13 *   07/21/98    stephen     Added GMT_PLUS, GMT_MINUS
     14 *                            Changed setTwoDigitStartDate to set2DigitYearStart
     15 *                            Changed getTwoDigitStartDate to get2DigitYearStart
     16 *                            Removed subParseLong
     17 *                            Removed getZoneIndex (added in DateFormatSymbols)
     18 *   06/14/99    stephen     Removed fgTimeZoneDataSuffix
     19 *   10/14/99    aliu        Updated class doc to describe 2-digit year parsing
     20 *                           {j28 4182066}.
     21 *******************************************************************************
     22 */
     23 
     24 #ifndef SMPDTFMT_H
     25 #define SMPDTFMT_H
     26 
     27 #include "unicode/utypes.h"
     28 
     29 /**
     30  * \file
     31  * \brief C++ API: Format and parse dates in a language-independent manner.
     32  */
     33 
     34 #if !UCONFIG_NO_FORMATTING
     35 
     36 #include "unicode/datefmt.h"
     37 #include "unicode/udisplaycontext.h"
     38 
     39 U_NAMESPACE_BEGIN
     40 
     41 class DateFormatSymbols;
     42 class DateFormat;
     43 class MessageFormat;
     44 class FieldPositionHandler;
     45 class TimeZoneFormat;
     46 
     47 /**
     48  *
     49  * SimpleDateFormat is a concrete class for formatting and parsing dates in a
     50  * language-independent manner. It allows for formatting (millis -> text),
     51  * parsing (text -> millis), and normalization. Formats/Parses a date or time,
     52  * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970.
     53  * <P>
     54  * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(),
     55  * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than
     56  * explicitly constructing an instance of SimpleDateFormat.  This way, the client
     57  * is guaranteed to get an appropriate formatting pattern for whatever locale the
     58  * program is running in.  However, if the client needs something more unusual than
     59  * the default patterns in the locales, he can construct a SimpleDateFormat directly
     60  * and give it an appropriate pattern (or use one of the factory methods on DateFormat
     61  * and modify the pattern after the fact with toPattern() and applyPattern().
     62  * <P>
     63  * Date/Time format syntax:
     64  * <P>
     65  * The date/time format is specified by means of a string time pattern. In this
     66  * pattern, all ASCII letters are reserved as pattern letters, which are defined
     67  * as the following:
     68  * <pre>
     69  * \code
     70  * Symbol   Meaning                 Presentation        Example
     71  * ------   -------                 ------------        -------
     72  * G        era designator          (Text)              AD
     73  * y        year                    (Number)            1996
     74  * Y        year (week of year)     (Number)            1997
     75  * u        extended year           (Number)            4601
     76  * U        cyclic year name        (Text,NumFallback)  ren-chen (29)
     77  * Q        Quarter                 (Text & Number)     Q2 & 02
     78  * M        month in year           (Text & Number)     July & 07
     79  * d        day in month            (Number)            10
     80  * h        hour in am/pm (1~12)    (Number)            12
     81  * H        hour in day (0~23)      (Number)            0
     82  * m        minute in hour          (Number)            30
     83  * s        second in minute        (Number)            55
     84  * S        fractional second       (Number)            978
     85  *          (maximum resolution of SSS; truncated if shorter, zero-padded if longer)
     86  * E        day of week             (Text)              Tuesday
     87  * e        day of week (local 1~7) (Text & Number)     Tues & 2
     88  * D        day in year             (Number)            189
     89  * F        day of week in month    (Number)            2 (2nd Wed in July)
     90  * w        week in year            (Number)            27
     91  * W        week in month           (Number)            2
     92  * a        am/pm marker            (Text)              PM
     93  * k        hour in day (1~24)      (Number)            24
     94  * K        hour in am/pm (0~11)    (Number)            0
     95  * z        time zone               (Text)              PST
     96  * zzzz     time zone               (Text)              Pacific Standard Time
     97  * Z        time zone (RFC 822)     (Number)            -0800
     98  * ZZZZ     time zone (RFC 822)     (Text & Number)     GMT-08:00
     99  * ZZZZZ    time zone (ISO 8601)    (Text & Number)     -08:00 & Z
    100  * v        time zone (generic)     (Text)              PT
    101  * vvvv     time zone (generic)     (Text)              Pacific Time
    102  * V        time zone (abreviation) (Text)              PST
    103  * VVVV     time zone (location)    (Text)              United States Time (Los Angeles)
    104  * g        Julian day              (Number)            2451334
    105  * A        milliseconds in day     (Number)            69540000
    106  * q        stand alone quarter     (Text & Number)     Q2 & 02
    107  * L        stand alone month       (Text & Number)     July & 07
    108  * c        stand alone day of week (Text & Number)     Tuesday & 2
    109  * '        escape for text         (Delimiter)         'Date='
    110  * ''       single quote            (Literal)           'o''clock'
    111  * \endcode
    112  * </pre>
    113  * The count of pattern letters determine the format.
    114  * <P>
    115  * (Text): 4 or more, use full form, &lt;4, use short or abbreviated form if it
    116  * exists. (e.g., "EEEE" produces "Monday", "EEE" produces "Mon")
    117  * <P>
    118  * (Number): the minimum number of digits. Shorter numbers are zero-padded to
    119  * this amount (e.g. if "m" produces "6", "mm" produces "06"). Year is handled
    120  * specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.
    121  * (e.g., if "yyyy" produces "1997", "yy" produces "97".)
    122  * Unlike other fields, fractional seconds are padded on the right with zero.
    123  * <P>
    124  * (Text & Number): 3 or over, use text, otherwise use number.  (e.g., "M" produces "1",
    125  * "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January".)
    126  * <P>
    127  * (Text,NumFallback): Behaves like Text if there is supporting data, like
    128  * Number otherwise.
    129  * <P>
    130  * Any characters in the pattern that are not in the ranges of ['a'..'z'] and
    131  * ['A'..'Z'] will be treated as quoted text. For instance, characters
    132  * like ':', '.', ' ', '#' and '@' will appear in the resulting time text
    133  * even they are not embraced within single quotes.
    134  * <P>
    135  * A pattern containing any invalid pattern letter will result in a failing
    136  * UErrorCode result during formatting or parsing.
    137  * <P>
    138  * Examples using the US locale:
    139  * <pre>
    140  * \code
    141  *    Format Pattern                         Result
    142  *    --------------                         -------
    143  *    "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->>  1996.07.10 AD at 15:08:56 Pacific Time
    144  *    "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96
    145  *    "h:mm a"                          ->>  12:08 PM
    146  *    "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time
    147  *    "K:mm a, vvv"                     ->>  0:00 PM, PT
    148  *    "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM
    149  * \endcode
    150  * </pre>
    151  * Code Sample:
    152  * <pre>
    153  * \code
    154  *     UErrorCode success = U_ZERO_ERROR;
    155  *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
    156  *     pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);
    157  *     pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);
    158  *
    159  *     // Format the current time.
    160  *     SimpleDateFormat* formatter
    161  *         = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success );
    162  *     GregorianCalendar cal(success);
    163  *     UDate currentTime_1 = cal.getTime(success);
    164  *     FieldPosition fp(0);
    165  *     UnicodeString dateString;
    166  *     formatter->format( currentTime_1, dateString, fp );
    167  *     cout << "result: " << dateString << endl;
    168  *
    169  *     // Parse the previous string back into a Date.
    170  *     ParsePosition pp(0);
    171  *     UDate currentTime_2 = formatter->parse(dateString, pp );
    172  * \endcode
    173  * </pre>
    174  * In the above example, the time value "currentTime_2" obtained from parsing
    175  * will be equal to currentTime_1. However, they may not be equal if the am/pm
    176  * marker 'a' is left out from the format pattern while the "hour in am/pm"
    177  * pattern symbol is used. This information loss can happen when formatting the
    178  * time in PM.
    179  *
    180  * <p>
    181  * When parsing a date string using the abbreviated year pattern ("y" or "yy"),
    182  * SimpleDateFormat must interpret the abbreviated year
    183  * relative to some century.  It does this by adjusting dates to be
    184  * within 80 years before and 20 years after the time the SimpleDateFormat
    185  * instance is created. For example, using a pattern of "MM/dd/yy" and a
    186  * SimpleDateFormat instance created on Jan 1, 1997,  the string
    187  * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64"
    188  * would be interpreted as May 4, 1964.
    189  * During parsing, only strings consisting of exactly two digits, as defined by
    190  * <code>Unicode::isDigit()</code>, will be parsed into the default century.
    191  * Any other numeric string, such as a one digit string, a three or more digit
    192  * string, or a two digit string that isn't all digits (for example, "-1"), is
    193  * interpreted literally.  So "01/02/3" or "01/02/003" are parsed (for the
    194  * Gregorian calendar), using the same pattern, as Jan 2, 3 AD.  Likewise (but
    195  * only in lenient parse mode, the default) "01/02/-3" is parsed as Jan 2, 4 BC.
    196  *
    197  * <p>
    198  * If the year pattern has more than two 'y' characters, the year is
    199  * interpreted literally, regardless of the number of digits.  So using the
    200  * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
    201  *
    202  * <p>
    203  * When numeric fields abut one another directly, with no intervening delimiter
    204  * characters, they constitute a run of abutting numeric fields.  Such runs are
    205  * parsed specially.  For example, the format "HHmmss" parses the input text
    206  * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to
    207  * parse "1234".  In other words, the leftmost field of the run is flexible,
    208  * while the others keep a fixed width.  If the parse fails anywhere in the run,
    209  * then the leftmost field is shortened by one character, and the entire run is
    210  * parsed again. This is repeated until either the parse succeeds or the
    211  * leftmost field is one character in length.  If the parse still fails at that
    212  * point, the parse of the run fails.
    213  *
    214  * <P>
    215  * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or
    216  * GMT-hours:minutes.
    217  * <P>
    218  * The calendar defines what is the first day of the week, the first week of the
    219  * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone.
    220  * There is one common number format to handle all the numbers; the digit count
    221  * is handled programmatically according to the pattern.
    222  *
    223  * <p><em>User subclasses are not supported.</em> While clients may write
    224  * subclasses, such code will not necessarily work and will not be
    225  * guaranteed to work stably from release to release.
    226  */
    227 class U_I18N_API SimpleDateFormat: public DateFormat {
    228 public:
    229     /**
    230      * Construct a SimpleDateFormat using the default pattern for the default
    231      * locale.
    232      * <P>
    233      * [Note:] Not all locales support SimpleDateFormat; for full generality,
    234      * use the factory methods in the DateFormat class.
    235      * @param status    Output param set to success/failure code.
    236      * @stable ICU 2.0
    237      */
    238     SimpleDateFormat(UErrorCode& status);
    239 
    240     /**
    241      * Construct a SimpleDateFormat using the given pattern and the default locale.
    242      * The locale is used to obtain the symbols used in formatting (e.g., the
    243      * names of the months), but not to provide the pattern.
    244      * <P>
    245      * [Note:] Not all locales support SimpleDateFormat; for full generality,
    246      * use the factory methods in the DateFormat class.
    247      * @param pattern    the pattern for the format.
    248      * @param status     Output param set to success/failure code.
    249      * @stable ICU 2.0
    250      */
    251     SimpleDateFormat(const UnicodeString& pattern,
    252                      UErrorCode& status);
    253 
    254     /**
    255      * Construct a SimpleDateFormat using the given pattern, numbering system override, and the default locale.
    256      * The locale is used to obtain the symbols used in formatting (e.g., the
    257      * names of the months), but not to provide the pattern.
    258      * <P>
    259      * A numbering system override is a string containing either the name of a known numbering system,
    260      * or a set of field and numbering system pairs that specify which fields are to be formattied with
    261      * the alternate numbering system.  For example, to specify that all numeric fields in the specified
    262      * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override
    263      * as "thai".  To specify that just the year portion of the date be formatted using Hebrew numbering,
    264      * use the override string "y=hebrew".  Numbering system overrides can be combined using a semi-colon
    265      * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc.
    266      *
    267      * <P>
    268      * [Note:] Not all locales support SimpleDateFormat; for full generality,
    269      * use the factory methods in the DateFormat class.
    270      * @param pattern    the pattern for the format.
    271      * @param override   the override string.
    272      * @param status     Output param set to success/failure code.
    273      * @stable ICU 4.2
    274      */
    275     SimpleDateFormat(const UnicodeString& pattern,
    276                      const UnicodeString& override,
    277                      UErrorCode& status);
    278 
    279     /**
    280      * Construct a SimpleDateFormat using the given pattern and locale.
    281      * The locale is used to obtain the symbols used in formatting (e.g., the
    282      * names of the months), but not to provide the pattern.
    283      * <P>
    284      * [Note:] Not all locales support SimpleDateFormat; for full generality,
    285      * use the factory methods in the DateFormat class.
    286      * @param pattern    the pattern for the format.
    287      * @param locale     the given locale.
    288      * @param status     Output param set to success/failure code.
    289      * @stable ICU 2.0
    290      */
    291     SimpleDateFormat(const UnicodeString& pattern,
    292                      const Locale& locale,
    293                      UErrorCode& status);
    294 
    295     /**
    296      * Construct a SimpleDateFormat using the given pattern, numbering system override, and locale.
    297      * The locale is used to obtain the symbols used in formatting (e.g., the
    298      * names of the months), but not to provide the pattern.
    299      * <P>
    300      * A numbering system override is a string containing either the name of a known numbering system,
    301      * or a set of field and numbering system pairs that specify which fields are to be formattied with
    302      * the alternate numbering system.  For example, to specify that all numeric fields in the specified
    303      * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override
    304      * as "thai".  To specify that just the year portion of the date be formatted using Hebrew numbering,
    305      * use the override string "y=hebrew".  Numbering system overrides can be combined using a semi-colon
    306      * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc.
    307      * <P>
    308      * [Note:] Not all locales support SimpleDateFormat; for full generality,
    309      * use the factory methods in the DateFormat class.
    310      * @param pattern    the pattern for the format.
    311      * @param override   the numbering system override.
    312      * @param locale     the given locale.
    313      * @param status     Output param set to success/failure code.
    314      * @stable ICU 4.2
    315      */
    316     SimpleDateFormat(const UnicodeString& pattern,
    317                      const UnicodeString& override,
    318                      const Locale& locale,
    319                      UErrorCode& status);
    320 
    321     /**
    322      * Construct a SimpleDateFormat using the given pattern and locale-specific
    323      * symbol data.  The formatter takes ownership of the DateFormatSymbols object;
    324      * the caller is no longer responsible for deleting it.
    325      * @param pattern           the given pattern for the format.
    326      * @param formatDataToAdopt the symbols to be adopted.
    327      * @param status            Output param set to success/faulure code.
    328      * @stable ICU 2.0
    329      */
    330     SimpleDateFormat(const UnicodeString& pattern,
    331                      DateFormatSymbols* formatDataToAdopt,
    332                      UErrorCode& status);
    333 
    334     /**
    335      * Construct a SimpleDateFormat using the given pattern and locale-specific
    336      * symbol data.  The DateFormatSymbols object is NOT adopted; the caller
    337      * remains responsible for deleting it.
    338      * @param pattern           the given pattern for the format.
    339      * @param formatData        the formatting symbols to be use.
    340      * @param status            Output param set to success/faulure code.
    341      * @stable ICU 2.0
    342      */
    343     SimpleDateFormat(const UnicodeString& pattern,
    344                      const DateFormatSymbols& formatData,
    345                      UErrorCode& status);
    346 
    347     /**
    348      * Copy constructor.
    349      * @stable ICU 2.0
    350      */
    351     SimpleDateFormat(const SimpleDateFormat&);
    352 
    353     /**
    354      * Assignment operator.
    355      * @stable ICU 2.0
    356      */
    357     SimpleDateFormat& operator=(const SimpleDateFormat&);
    358 
    359     /**
    360      * Destructor.
    361      * @stable ICU 2.0
    362      */
    363     virtual ~SimpleDateFormat();
    364 
    365     /**
    366      * Clone this Format object polymorphically. The caller owns the result and
    367      * should delete it when done.
    368      * @return    A copy of the object.
    369      * @stable ICU 2.0
    370      */
    371     virtual Format* clone(void) const;
    372 
    373     /**
    374      * Return true if the given Format objects are semantically equal. Objects
    375      * of different subclasses are considered unequal.
    376      * @param other    the object to be compared with.
    377      * @return         true if the given Format objects are semantically equal.
    378      * @stable ICU 2.0
    379      */
    380     virtual UBool operator==(const Format& other) const;
    381 
    382 
    383     using DateFormat::format;
    384 
    385     /**
    386      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
    387      * 1, 1970. Overrides DateFormat pure virtual method.
    388      * <P>
    389      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
    390      * 1996.07.10 AD at 15:08:56 PDT
    391      *
    392      * @param cal       Calendar set to the date and time to be formatted
    393      *                  into a date/time string.
    394      * @param appendTo  Output parameter to receive result.
    395      *                  Result is appended to existing contents.
    396      * @param pos       The formatting position. On input: an alignment field,
    397      *                  if desired. On output: the offsets of the alignment field.
    398      * @return          Reference to 'appendTo' parameter.
    399      * @stable ICU 2.1
    400      */
    401     virtual UnicodeString& format(  Calendar& cal,
    402                                     UnicodeString& appendTo,
    403                                     FieldPosition& pos) const;
    404 
    405     /**
    406      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
    407      * 1, 1970. Overrides DateFormat pure virtual method.
    408      * <P>
    409      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
    410      * 1996.07.10 AD at 15:08:56 PDT
    411      *
    412      * @param cal       Calendar set to the date and time to be formatted
    413      *                  into a date/time string.
    414      * @param appendTo  Output parameter to receive result.
    415      *                  Result is appended to existing contents.
    416      * @param posIter   On return, can be used to iterate over positions
    417      *                  of fields generated by this format call.  Field values
    418      *                  are defined in UDateFormatField.
    419      * @param status    Input/output param set to success/failure code.
    420      * @return          Reference to 'appendTo' parameter.
    421      * @stable ICU 4.4
    422      */
    423     virtual UnicodeString& format(  Calendar& cal,
    424                                     UnicodeString& appendTo,
    425                                     FieldPositionIterator* posIter,
    426                                     UErrorCode& status) const;
    427 
    428     /**
    429      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
    430      * 1, 1970. Overrides DateFormat pure virtual method.
    431      * <P>
    432      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
    433      * 1996.07.10 AD at 15:08:56 PDT
    434      *
    435      * @param obj       A Formattable containing the date-time value to be formatted
    436      *                  into a date-time string.  If the type of the Formattable
    437      *                  is a numeric type, it is treated as if it were an
    438      *                  instance of Date.
    439      * @param appendTo  Output parameter to receive result.
    440      *                  Result is appended to existing contents.
    441      * @param pos       The formatting position. On input: an alignment field,
    442      *                  if desired. On output: the offsets of the alignment field.
    443      * @param status    Input/output param set to success/failure code.
    444      * @return          Reference to 'appendTo' parameter.
    445      * @stable ICU 2.0
    446      */
    447     virtual UnicodeString& format(  const Formattable& obj,
    448                                     UnicodeString& appendTo,
    449                                     FieldPosition& pos,
    450                                     UErrorCode& status) const;
    451 
    452     /**
    453      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
    454      * 1, 1970. Overrides DateFormat pure virtual method.
    455      * <P>
    456      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
    457      * 1996.07.10 AD at 15:08:56 PDT
    458      *
    459      * @param obj       A Formattable containing the date-time value to be formatted
    460      *                  into a date-time string.  If the type of the Formattable
    461      *                  is a numeric type, it is treated as if it were an
    462      *                  instance of Date.
    463      * @param appendTo  Output parameter to receive result.
    464      *                  Result is appended to existing contents.
    465      * @param posIter   On return, can be used to iterate over positions
    466      *                  of fields generated by this format call.  Field values
    467      *                  are defined in UDateFormatField.
    468      * @param status    Input/output param set to success/failure code.
    469      * @return          Reference to 'appendTo' parameter.
    470      * @stable ICU 4.4
    471      */
    472     virtual UnicodeString& format(  const Formattable& obj,
    473                                     UnicodeString& appendTo,
    474                                     FieldPositionIterator* posIter,
    475                                     UErrorCode& status) const;
    476 
    477     /**
    478      * Redeclared DateFormat method.
    479      * @param date          the Date value to be formatted.
    480      * @param appendTo      Output parameter to receive result.
    481      *                      Result is appended to existing contents.
    482      * @param fieldPosition The formatting position. On input: an alignment field,
    483      *                      if desired. On output: the offsets of the alignment field.
    484      * @return              Reference to 'appendTo' parameter.
    485      * @stable ICU 2.1
    486      */
    487     UnicodeString& format(UDate date,
    488                           UnicodeString& appendTo,
    489                           FieldPosition& fieldPosition) const;
    490 
    491     /**
    492      * Redeclared DateFormat method.
    493      * @param date          the Date value to be formatted.
    494      * @param appendTo      Output parameter to receive result.
    495      *                      Result is appended to existing contents.
    496      * @param posIter       On return, can be used to iterate over positions
    497      *                      of fields generated by this format call.  Field values
    498      *                      are defined in UDateFormatField.
    499      * @param status        Input/output param set to success/failure code.
    500      * @return              Reference to 'appendTo' parameter.
    501      * @stable ICU 4.4
    502      */
    503     UnicodeString& format(UDate date,
    504                           UnicodeString& appendTo,
    505                           FieldPositionIterator* posIter,
    506                           UErrorCode& status) const;
    507 
    508     /**
    509      * Redeclared DateFormat method.
    510      * @param obj       Object to be formatted.
    511      * @param appendTo  Output parameter to receive result.
    512      *                  Result is appended to existing contents.
    513      * @param status    Input/output success/failure code.
    514      * @return          Reference to 'appendTo' parameter.
    515      * @stable ICU 2.0
    516      */
    517     UnicodeString& format(const Formattable& obj,
    518                           UnicodeString& appendTo,
    519                           UErrorCode& status) const;
    520 
    521     /**
    522      * Redeclared DateFormat method.
    523      * @param date      Date value to be formatted.
    524      * @param appendTo  Output parameter to receive result.
    525      *                  Result is appended to existing contents.
    526      * @return          Reference to 'appendTo' parameter.
    527      * @stable ICU 2.0
    528      */
    529     UnicodeString& format(UDate date, UnicodeString& appendTo) const;
    530 
    531     /**
    532      * Parse a date/time string beginning at the given parse position. For
    533      * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
    534      * that is equivalent to Date(837039928046).
    535      * <P>
    536      * By default, parsing is lenient: If the input is not in the form used by
    537      * this object's format method but can still be parsed as a date, then the
    538      * parse succeeds. Clients may insist on strict adherence to the format by
    539      * calling setLenient(false).
    540      * @see DateFormat::setLenient(boolean)
    541      *
    542      * @param text  The date/time string to be parsed
    543      * @param cal   A Calendar set on input to the date and time to be used for
    544      *              missing values in the date/time string being parsed, and set
    545      *              on output to the parsed date/time. When the calendar type is
    546      *              different from the internal calendar held by this SimpleDateFormat
    547      *              instance, the internal calendar will be cloned to a work
    548      *              calendar set to the same milliseconds and time zone as the
    549      *              cal parameter, field values will be parsed based on the work
    550      *              calendar, then the result (milliseconds and time zone) will
    551      *              be set in this calendar.
    552      * @param pos   On input, the position at which to start parsing; on
    553      *              output, the position at which parsing terminated, or the
    554      *              start position if the parse failed.
    555      * @stable ICU 2.1
    556      */
    557     virtual void parse( const UnicodeString& text,
    558                         Calendar& cal,
    559                         ParsePosition& pos) const;
    560 
    561     /**
    562      * Parse a date/time string starting at the given parse position. For
    563      * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
    564      * that is equivalent to Date(837039928046).
    565      * <P>
    566      * By default, parsing is lenient: If the input is not in the form used by
    567      * this object's format method but can still be parsed as a date, then the
    568      * parse succeeds. Clients may insist on strict adherence to the format by
    569      * calling setLenient(false).
    570      * @see DateFormat::setLenient(boolean)
    571      * <P>
    572      * Note that the normal date formats associated with some calendars - such
    573      * as the Chinese lunar calendar - do not specify enough fields to enable
    574      * dates to be parsed unambiguously. In the case of the Chinese lunar
    575      * calendar, while the year within the current 60-year cycle is specified,
    576      * the number of such cycles since the start date of the calendar (in the
    577      * ERA field of the Calendar object) is not normally part of the format,
    578      * and parsing may assume the wrong era. For cases such as this it is
    579      * recommended that clients parse using the method
    580      * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
    581      * with the Calendar passed in set to the current date, or to a date
    582      * within the era/cycle that should be assumed if absent in the format.
    583      *
    584      * @param text  The date/time string to be parsed
    585      * @param pos   On input, the position at which to start parsing; on
    586      *              output, the position at which parsing terminated, or the
    587      *              start position if the parse failed.
    588      * @return      A valid UDate if the input could be parsed.
    589      * @stable ICU 2.0
    590      */
    591     UDate parse( const UnicodeString& text,
    592                  ParsePosition& pos) const;
    593 
    594 
    595     /**
    596      * Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
    597      * will be parsed into a UDate that is equivalent to Date(837039928046).
    598      * Parsing begins at the beginning of the string and proceeds as far as
    599      * possible.  Assuming no parse errors were encountered, this function
    600      * doesn't return any information about how much of the string was consumed
    601      * by the parsing.  If you need that information, use the version of
    602      * parse() that takes a ParsePosition.
    603      * <P>
    604      * By default, parsing is lenient: If the input is not in the form used by
    605      * this object's format method but can still be parsed as a date, then the
    606      * parse succeeds. Clients may insist on strict adherence to the format by
    607      * calling setLenient(false).
    608      * @see DateFormat::setLenient(boolean)
    609      * <P>
    610      * Note that the normal date formats associated with some calendars - such
    611      * as the Chinese lunar calendar - do not specify enough fields to enable
    612      * dates to be parsed unambiguously. In the case of the Chinese lunar
    613      * calendar, while the year within the current 60-year cycle is specified,
    614      * the number of such cycles since the start date of the calendar (in the
    615      * ERA field of the Calendar object) is not normally part of the format,
    616      * and parsing may assume the wrong era. For cases such as this it is
    617      * recommended that clients parse using the method
    618      * parse(const UnicodeString&, Calendar& cal, ParsePosition&)
    619      * with the Calendar passed in set to the current date, or to a date
    620      * within the era/cycle that should be assumed if absent in the format.
    621      *
    622      * @param text  The date/time string to be parsed into a UDate value.
    623      * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
    624      *              an error value if there was a parse error.
    625      * @return      A valid UDate if the input could be parsed.
    626      * @stable ICU 2.0
    627      */
    628     virtual UDate parse( const UnicodeString& text,
    629                         UErrorCode& status) const;
    630 
    631     /**
    632      * Set the start UDate used to interpret two-digit year strings.
    633      * When dates are parsed having 2-digit year strings, they are placed within
    634      * a assumed range of 100 years starting on the two digit start date.  For
    635      * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
    636      * some other year.  SimpleDateFormat chooses a year so that the resultant
    637      * date is on or after the two digit start date and within 100 years of the
    638      * two digit start date.
    639      * <P>
    640      * By default, the two digit start date is set to 80 years before the current
    641      * time at which a SimpleDateFormat object is created.
    642      * @param d      start UDate used to interpret two-digit year strings.
    643      * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
    644      *               an error value if there was a parse error.
    645      * @stable ICU 2.0
    646      */
    647     virtual void set2DigitYearStart(UDate d, UErrorCode& status);
    648 
    649     /**
    650      * Get the start UDate used to interpret two-digit year strings.
    651      * When dates are parsed having 2-digit year strings, they are placed within
    652      * a assumed range of 100 years starting on the two digit start date.  For
    653      * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
    654      * some other year.  SimpleDateFormat chooses a year so that the resultant
    655      * date is on or after the two digit start date and within 100 years of the
    656      * two digit start date.
    657      * <P>
    658      * By default, the two digit start date is set to 80 years before the current
    659      * time at which a SimpleDateFormat object is created.
    660      * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
    661      *               an error value if there was a parse error.
    662      * @stable ICU 2.0
    663      */
    664     UDate get2DigitYearStart(UErrorCode& status) const;
    665 
    666     /**
    667      * Return a pattern string describing this date format.
    668      * @param result Output param to receive the pattern.
    669      * @return       A reference to 'result'.
    670      * @stable ICU 2.0
    671      */
    672     virtual UnicodeString& toPattern(UnicodeString& result) const;
    673 
    674     /**
    675      * Return a localized pattern string describing this date format.
    676      * In most cases, this will return the same thing as toPattern(),
    677      * but a locale can specify characters to use in pattern descriptions
    678      * in place of the ones described in this class's class documentation.
    679      * (Presumably, letters that would be more mnemonic in that locale's
    680      * language.)  This function would produce a pattern using those
    681      * letters.
    682      *
    683      * @param result    Receives the localized pattern.
    684      * @param status    Output param set to success/failure code on
    685      *                  exit. If the pattern is invalid, this will be
    686      *                  set to a failure result.
    687      * @return          A reference to 'result'.
    688      * @stable ICU 2.0
    689      */
    690     virtual UnicodeString& toLocalizedPattern(UnicodeString& result,
    691                                               UErrorCode& status) const;
    692 
    693     /**
    694      * Apply the given unlocalized pattern string to this date format.
    695      * (i.e., after this call, this formatter will format dates according to
    696      * the new pattern)
    697      *
    698      * @param pattern   The pattern to be applied.
    699      * @stable ICU 2.0
    700      */
    701     virtual void applyPattern(const UnicodeString& pattern);
    702 
    703     /**
    704      * Apply the given localized pattern string to this date format.
    705      * (see toLocalizedPattern() for more information on localized patterns.)
    706      *
    707      * @param pattern   The localized pattern to be applied.
    708      * @param status    Output param set to success/failure code on
    709      *                  exit. If the pattern is invalid, this will be
    710      *                  set to a failure result.
    711      * @stable ICU 2.0
    712      */
    713     virtual void applyLocalizedPattern(const UnicodeString& pattern,
    714                                        UErrorCode& status);
    715 
    716     /**
    717      * Gets the date/time formatting symbols (this is an object carrying
    718      * the various strings and other symbols used in formatting: e.g., month
    719      * names and abbreviations, time zone names, AM/PM strings, etc.)
    720      * @return a copy of the date-time formatting data associated
    721      * with this date-time formatter.
    722      * @stable ICU 2.0
    723      */
    724     virtual const DateFormatSymbols* getDateFormatSymbols(void) const;
    725 
    726     /**
    727      * Set the date/time formatting symbols.  The caller no longer owns the
    728      * DateFormatSymbols object and should not delete it after making this call.
    729      * @param newFormatSymbols the given date-time formatting symbols to copy.
    730      * @stable ICU 2.0
    731      */
    732     virtual void adoptDateFormatSymbols(DateFormatSymbols* newFormatSymbols);
    733 
    734     /**
    735      * Set the date/time formatting data.
    736      * @param newFormatSymbols the given date-time formatting symbols to copy.
    737      * @stable ICU 2.0
    738      */
    739     virtual void setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols);
    740 
    741     /**
    742      * Return the class ID for this class. This is useful only for comparing to
    743      * a return value from getDynamicClassID(). For example:
    744      * <pre>
    745      * .   Base* polymorphic_pointer = createPolymorphicObject();
    746      * .   if (polymorphic_pointer->getDynamicClassID() ==
    747      * .       erived::getStaticClassID()) ...
    748      * </pre>
    749      * @return          The class ID for all objects of this class.
    750      * @stable ICU 2.0
    751      */
    752     static UClassID U_EXPORT2 getStaticClassID(void);
    753 
    754     /**
    755      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
    756      * method is to implement a simple version of RTTI, since not all C++
    757      * compilers support genuine RTTI. Polymorphic operator==() and clone()
    758      * methods call this method.
    759      *
    760      * @return          The class ID for this object. All objects of a
    761      *                  given class have the same class ID.  Objects of
    762      *                  other classes have different class IDs.
    763      * @stable ICU 2.0
    764      */
    765     virtual UClassID getDynamicClassID(void) const;
    766 
    767     /**
    768      * Set the calendar to be used by this date format. Initially, the default
    769      * calendar for the specified or default locale is used.  The caller should
    770      * not delete the Calendar object after it is adopted by this call.
    771      * Adopting a new calendar will change to the default symbols.
    772      *
    773      * @param calendarToAdopt    Calendar object to be adopted.
    774      * @stable ICU 2.0
    775      */
    776     virtual void adoptCalendar(Calendar* calendarToAdopt);
    777 
    778     /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual */
    779     /**
    780      * Set a particular UDisplayContext value in the formatter, such as
    781      * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
    782      * @param value The UDisplayContext value to set.
    783      * @param status Input/output status. If at entry this indicates a failure
    784      *               status, the function will do nothing; otherwise this will be
    785      *               updated with any new status from the function.
    786      * @internal ICU 50 technology preview
    787      */
    788     virtual void setContext(UDisplayContext value, UErrorCode& status);
    789 
    790     /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual */
    791     /**
    792      * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
    793      * such as UDISPCTX_TYPE_CAPITALIZATION.
    794      * @param type The UDisplayContextType whose value to return
    795      * @param status Input/output status. If at entry this indicates a failure
    796      *               status, the function will do nothing; otherwise this will be
    797      *               updated with any new status from the function.
    798      * @return The UDisplayContextValue for the specified type.
    799      * @internal ICU 50 technology preview
    800      */
    801     virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
    802 
    803     /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since they are virtual */
    804     /**
    805      * Sets the TimeZoneFormat to be used by this date/time formatter.
    806      * The caller should not delete the TimeZoneFormat object after
    807      * it is adopted by this call.
    808      * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted.
    809      * @internal ICU 49 technology preview
    810      */
    811     virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt);
    812 
    813     /**
    814      * Sets the TimeZoneFormat to be used by this date/time formatter.
    815      * @param newTimeZoneFormat The TimeZoneFormat object to copy.
    816      * @internal ICU 49 technology preview
    817      */
    818     virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat);
    819 
    820     /**
    821      * Gets the time zone format object associated with this date/time formatter.
    822      * @return the time zone format associated with this date/time formatter.
    823      * @internal ICU 49 technology preview
    824      */
    825     virtual const TimeZoneFormat* getTimeZoneFormat(void) const;
    826 
    827 #ifndef U_HIDE_INTERNAL_API
    828     /**
    829      * This is for ICU internal use only. Please do not use.
    830      * Check whether the 'field' is smaller than all the fields covered in
    831      * pattern, return TRUE if it is. The sequence of calendar field,
    832      * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
    833      * @param field    the calendar field need to check against
    834      * @return         TRUE if the 'field' is smaller than all the fields
    835      *                 covered in pattern. FALSE otherwise.
    836      * @internal ICU 4.0
    837      */
    838     UBool isFieldUnitIgnored(UCalendarDateFields field) const;
    839 
    840 
    841     /**
    842      * This is for ICU internal use only. Please do not use.
    843      * Check whether the 'field' is smaller than all the fields covered in
    844      * pattern, return TRUE if it is. The sequence of calendar field,
    845      * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
    846      * @param pattern  the pattern to check against
    847      * @param field    the calendar field need to check against
    848      * @return         TRUE if the 'field' is smaller than all the fields
    849      *                 covered in pattern. FALSE otherwise.
    850      * @internal ICU 4.0
    851      */
    852     static UBool isFieldUnitIgnored(const UnicodeString& pattern,
    853                                     UCalendarDateFields field);
    854 
    855     /**
    856      * This is for ICU internal use only. Please do not use.
    857      * Get the locale of this simple date formatter.
    858      * It is used in DateIntervalFormat.
    859      *
    860      * @return   locale in this simple date formatter
    861      * @internal ICU 4.0
    862      */
    863     const Locale& getSmpFmtLocale(void) const;
    864 #endif  /* U_HIDE_INTERNAL_API */
    865 
    866 private:
    867     friend class DateFormat;
    868 
    869     void initializeDefaultCentury(void);
    870 
    871     SimpleDateFormat(); // default constructor not implemented
    872 
    873     /**
    874      * Used by the DateFormat factory methods to construct a SimpleDateFormat.
    875      * @param timeStyle the time style.
    876      * @param dateStyle the date style.
    877      * @param locale    the given locale.
    878      * @param status    Output param set to success/failure code on
    879      *                  exit.
    880      */
    881     SimpleDateFormat(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
    882 
    883     /**
    884      * Construct a SimpleDateFormat for the given locale.  If no resource data
    885      * is available, create an object of last resort, using hard-coded strings.
    886      * This is an internal method, called by DateFormat.  It should never fail.
    887      * @param locale    the given locale.
    888      * @param status    Output param set to success/failure code on
    889      *                  exit.
    890      */
    891     SimpleDateFormat(const Locale& locale, UErrorCode& status); // Use default pattern
    892 
    893     /**
    894      * Hook called by format(... FieldPosition& ...) and format(...FieldPositionIterator&...)
    895      */
    896     UnicodeString& _format(Calendar& cal, UnicodeString& appendTo, FieldPositionHandler& handler, UErrorCode& status) const;
    897 
    898     /**
    899      * Called by format() to format a single field.
    900      *
    901      * @param appendTo  Output parameter to receive result.
    902      *                  Result is appended to existing contents.
    903      * @param ch        The format character we encountered in the pattern.
    904      * @param count     Number of characters in the current pattern symbol (e.g.,
    905      *                  "yyyy" in the pattern would result in a call to this function
    906      *                  with ch equal to 'y' and count equal to 4)
    907      * @param capitalizationContext Capitalization context for this date format.
    908      * @param fieldNum  Zero-based numbering of current field within the overall format.
    909      * @param handler   Records information about field positions.
    910      * @param cal       Calendar to use
    911      * @param status    Receives a status code, which will be U_ZERO_ERROR if the operation
    912      *                  succeeds.
    913      */
    914     void subFormat(UnicodeString &appendTo,
    915                    UChar ch,
    916                    int32_t count,
    917                    UDisplayContext capitalizationContext,
    918                    int32_t fieldNum,
    919                    FieldPositionHandler& handler,
    920                    Calendar& cal,
    921                    UErrorCode& status) const; // in case of illegal argument
    922 
    923     /**
    924      * Used by subFormat() to format a numeric value.
    925      * Appends to toAppendTo a string representation of "value"
    926      * having a number of digits between "minDigits" and
    927      * "maxDigits".  Uses the DateFormat's NumberFormat.
    928      *
    929      * @param currentNumberFormat
    930      * @param appendTo  Output parameter to receive result.
    931      *                  Formatted number is appended to existing contents.
    932      * @param value     Value to format.
    933      * @param minDigits Minimum number of digits the result should have
    934      * @param maxDigits Maximum number of digits the result should have
    935      */
    936     void zeroPaddingNumber(NumberFormat *currentNumberFormat,
    937                            UnicodeString &appendTo,
    938                            int32_t value,
    939                            int32_t minDigits,
    940                            int32_t maxDigits) const;
    941 
    942     /**
    943      * Return true if the given format character, occuring count
    944      * times, represents a numeric field.
    945      */
    946     static UBool isNumeric(UChar formatChar, int32_t count);
    947 
    948     /**
    949      * Returns TRUE if the patternOffset is at the start of a numeric field.
    950      */
    951     static UBool isAtNumericField(const UnicodeString &pattern, int32_t patternOffset);
    952 
    953     /**
    954      * Returns TRUE if the patternOffset is right after a non-numeric field.
    955      */
    956     static UBool isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset);
    957 
    958     /**
    959      * initializes fCalendar from parameters.  Returns fCalendar as a convenience.
    960      * @param adoptZone  Zone to be adopted, or NULL for TimeZone::createDefault().
    961      * @param locale Locale of the calendar
    962      * @param status Error code
    963      * @return the newly constructed fCalendar
    964      */
    965     Calendar *initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status);
    966 
    967     /**
    968      * initializes fSymbols from parameters.
    969      * @param locale Locale of the symbols
    970      * @param calendar Alias to Calendar that will be used.
    971      * @param status Error code
    972      */
    973     void initializeSymbols(const Locale& locale, Calendar* calendar, UErrorCode& status);
    974 
    975     /**
    976      * Called by several of the constructors to load pattern data and formatting symbols
    977      * out of a resource bundle and initialize the locale based on it.
    978      * @param timeStyle     The time style, as passed to DateFormat::createDateInstance().
    979      * @param dateStyle     The date style, as passed to DateFormat::createTimeInstance().
    980      * @param locale        The locale to load the patterns from.
    981      * @param status        Filled in with an error code if loading the data from the
    982      *                      resources fails.
    983      */
    984     void construct(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
    985 
    986     /**
    987      * Called by construct() and the various constructors to set up the SimpleDateFormat's
    988      * Calendar and NumberFormat objects.
    989      * @param locale    The locale for which we want a Calendar and a NumberFormat.
    990      * @param status    Filled in with an error code if creating either subobject fails.
    991      */
    992     void initialize(const Locale& locale, UErrorCode& status);
    993 
    994     /**
    995      * Private code-size reduction function used by subParse.
    996      * @param text the time text being parsed.
    997      * @param start where to start parsing.
    998      * @param field the date field being parsed.
    999      * @param stringArray the string array to parsed.
   1000      * @param stringArrayCount the size of the array.
   1001      * @param monthPattern pointer to leap month pattern, or NULL if none.
   1002      * @param cal a Calendar set to the date and time to be formatted
   1003      *            into a date/time string.
   1004      * @return the new start position if matching succeeded; a negative number
   1005      * indicating matching failure, otherwise.
   1006      */
   1007     int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
   1008                         const UnicodeString* stringArray, int32_t stringArrayCount,
   1009                         const UnicodeString* monthPattern, Calendar& cal) const;
   1010 
   1011     /**
   1012      * Private code-size reduction function used by subParse.
   1013      * @param text the time text being parsed.
   1014      * @param start where to start parsing.
   1015      * @param field the date field being parsed.
   1016      * @param stringArray the string array to parsed.
   1017      * @param stringArrayCount the size of the array.
   1018      * @param cal a Calendar set to the date and time to be formatted
   1019      *            into a date/time string.
   1020      * @return the new start position if matching succeeded; a negative number
   1021      * indicating matching failure, otherwise.
   1022      */
   1023     int32_t matchQuarterString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
   1024                                const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;
   1025 
   1026     /**
   1027      * Private function used by subParse to match literal pattern text.
   1028      *
   1029      * @param pattern the pattern string
   1030      * @param patternOffset the starting offset into the pattern text. On
   1031      *        outupt will be set the offset of the first non-literal character in the pattern
   1032      * @param text the text being parsed
   1033      * @param textOffset the starting offset into the text. On output
   1034      *                   will be set to the offset of the character after the match
   1035      * @param lenient <code>TRUE</code> if the parse is lenient, <code>FALSE</code> otherwise.
   1036      *
   1037      * @return <code>TRUE</code> if the literal text could be matched, <code>FALSE</code> otherwise.
   1038      */
   1039     static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOffset,
   1040                                const UnicodeString &text, int32_t &textOffset, UBool lenient);
   1041 
   1042     /**
   1043      * Private member function that converts the parsed date strings into
   1044      * timeFields. Returns -start (for ParsePosition) if failed.
   1045      * @param text the time text to be parsed.
   1046      * @param start where to start parsing.
   1047      * @param ch the pattern character for the date field text to be parsed.
   1048      * @param count the count of a pattern character.
   1049      * @param obeyCount if true then the count is strictly obeyed.
   1050      * @param allowNegative
   1051      * @param ambiguousYear If true then the two-digit year == the default start year.
   1052      * @param saveHebrewMonth Used to hang onto month until year is known.
   1053      * @param cal a Calendar set to the date and time to be formatted
   1054      *            into a date/time string.
   1055      * @param patLoc
   1056      * @param numericLeapMonthFormatter If non-null, used to parse numeric leap months.
   1057      * @return the new start position if matching succeeded; a negative number
   1058      * indicating matching failure, otherwise.
   1059      */
   1060     int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
   1061                      UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
   1062                      int32_t patLoc, MessageFormat * numericLeapMonthFormatter) const;
   1063 
   1064     void parseInt(const UnicodeString& text,
   1065                   Formattable& number,
   1066                   ParsePosition& pos,
   1067                   UBool allowNegative,
   1068                   NumberFormat *fmt) const;
   1069 
   1070     void parseInt(const UnicodeString& text,
   1071                   Formattable& number,
   1072                   int32_t maxDigits,
   1073                   ParsePosition& pos,
   1074                   UBool allowNegative,
   1075                   NumberFormat *fmt) const;
   1076 
   1077     int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
   1078                            int32_t patLoc, UBool isNegative) const;
   1079 
   1080     /**
   1081      * Translate a pattern, mapping each character in the from string to the
   1082      * corresponding character in the to string. Return an error if the original
   1083      * pattern contains an unmapped character, or if a quote is unmatched.
   1084      * Quoted (single quotes only) material is not translated.
   1085      * @param originalPattern   the original pattern.
   1086      * @param translatedPattern Output param to receive the translited pattern.
   1087      * @param from              the characters to be translited from.
   1088      * @param to                the characters to be translited to.
   1089      * @param status            Receives a status code, which will be U_ZERO_ERROR
   1090      *                          if the operation succeeds.
   1091      */
   1092     static void translatePattern(const UnicodeString& originalPattern,
   1093                                 UnicodeString& translatedPattern,
   1094                                 const UnicodeString& from,
   1095                                 const UnicodeString& to,
   1096                                 UErrorCode& status);
   1097 
   1098     /**
   1099      * Sets the starting date of the 100-year window that dates with 2-digit years
   1100      * are considered to fall within.
   1101      * @param startDate the start date
   1102      * @param status    Receives a status code, which will be U_ZERO_ERROR
   1103      *                  if the operation succeeds.
   1104      */
   1105     void         parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& status);
   1106 
   1107     /**
   1108      * Return the length matched by the given affix, or -1 if none.
   1109      * Runs of white space in the affix, match runs of white space in
   1110      * the input.
   1111      * @param affix pattern string, taken as a literal
   1112      * @param input input text
   1113      * @param pos offset into input at which to begin matching
   1114      * @return length of input that matches, or -1 if match failure
   1115      */
   1116     int32_t compareSimpleAffix(const UnicodeString& affix,
   1117                    const UnicodeString& input,
   1118                    int32_t pos) const;
   1119 
   1120     /**
   1121      * Skip over a run of zero or more Pattern_White_Space characters at
   1122      * pos in text.
   1123      */
   1124     int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const;
   1125 
   1126     /**
   1127      * Skip over a run of zero or more isUWhiteSpace() characters at pos
   1128      * in text.
   1129      */
   1130     int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos) const;
   1131 
   1132     /**
   1133      * Initialize NumberFormat instances used for numbering system overrides.
   1134      */
   1135     void initNumberFormatters(const Locale &locale,UErrorCode &status);
   1136 
   1137     /**
   1138      * Get the numbering system to be used for a particular field.
   1139      */
   1140      NumberFormat * getNumberFormatByIndex(UDateFormatField index) const;
   1141 
   1142     /**
   1143      * Parse the given override string and set up structures for number formats
   1144      */
   1145     void processOverrideString(const Locale &locale, const UnicodeString &str, int8_t type, UErrorCode &status);
   1146 
   1147     /**
   1148      * Used to map pattern characters to Calendar field identifiers.
   1149      */
   1150     static const UCalendarDateFields fgPatternIndexToCalendarField[];
   1151 
   1152     /**
   1153      * Map index into pattern character string to DateFormat field number
   1154      */
   1155     static const UDateFormatField fgPatternIndexToDateFormatField[];
   1156 
   1157     /**
   1158      * Lazy TimeZoneFormat instantiation, semantically const
   1159      */
   1160     TimeZoneFormat *tzFormat() const;
   1161 
   1162     /**
   1163      * Used to map Calendar field to field level.
   1164      * The larger the level, the smaller the field unit.
   1165      * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10,
   1166      * UCAL_MONTH level is 20.
   1167      */
   1168     static const int32_t fgCalendarFieldToLevel[];
   1169     static const int32_t fgPatternCharToLevel[];
   1170 
   1171     /**
   1172      * The formatting pattern for this formatter.
   1173      */
   1174     UnicodeString       fPattern;
   1175 
   1176     /**
   1177      * The numbering system override for dates.
   1178      */
   1179     UnicodeString       fDateOverride;
   1180 
   1181     /**
   1182      * The numbering system override for times.
   1183      */
   1184     UnicodeString       fTimeOverride;
   1185 
   1186 
   1187     /**
   1188      * The original locale used (for reloading symbols)
   1189      */
   1190     Locale              fLocale;
   1191 
   1192     /**
   1193      * A pointer to an object containing the strings to use in formatting (e.g.,
   1194      * month and day names, AM and PM strings, time zone names, etc.)
   1195      */
   1196     DateFormatSymbols*  fSymbols;   // Owned
   1197 
   1198     /**
   1199      * The time zone formatter
   1200      */
   1201     TimeZoneFormat* fTimeZoneFormat;
   1202 
   1203     /**
   1204      * If dates have ambiguous years, we map them into the century starting
   1205      * at defaultCenturyStart, which may be any date.  If defaultCenturyStart is
   1206      * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system
   1207      * values are used.  The instance values defaultCenturyStart and
   1208      * defaultCenturyStartYear are only used if explicitly set by the user
   1209      * through the API method parseAmbiguousDatesAsAfter().
   1210      */
   1211     UDate                fDefaultCenturyStart;
   1212 
   1213     /**
   1214      * See documentation for defaultCenturyStart.
   1215      */
   1216     /*transient*/ int32_t   fDefaultCenturyStartYear;
   1217 
   1218     int32_t tztype; // here to avoid api change
   1219 
   1220     typedef struct NSOverride {
   1221         NumberFormat *nf;
   1222         int32_t hash;
   1223         NSOverride *next;
   1224     } NSOverride;
   1225 
   1226     NumberFormat    **fNumberFormatters;
   1227 
   1228     NSOverride      *fOverrideList;
   1229 
   1230     UBool fHaveDefaultCentury;
   1231 
   1232     UDisplayContext fCapitalizationContext;
   1233 };
   1234 
   1235 inline UDate
   1236 SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const
   1237 {
   1238     return fDefaultCenturyStart;
   1239 }
   1240 
   1241 inline UnicodeString&
   1242 SimpleDateFormat::format(const Formattable& obj,
   1243                          UnicodeString& appendTo,
   1244                          UErrorCode& status) const {
   1245     // Don't use Format:: - use immediate base class only,
   1246     // in case immediate base modifies behavior later.
   1247     return DateFormat::format(obj, appendTo, status);
   1248 }
   1249 
   1250 inline UnicodeString&
   1251 SimpleDateFormat::format(const Formattable& obj,
   1252                          UnicodeString& appendTo,
   1253                          FieldPosition& pos,
   1254                          UErrorCode& status) const
   1255 {
   1256     // Don't use Format:: - use immediate base class only,
   1257     // in case immediate base modifies behavior later.
   1258     return DateFormat::format(obj, appendTo, pos, status);
   1259 }
   1260 
   1261 inline UnicodeString&
   1262 SimpleDateFormat::format(const Formattable& obj,
   1263                          UnicodeString& appendTo,
   1264                          FieldPositionIterator* posIter,
   1265                          UErrorCode& status) const
   1266 {
   1267     // Don't use Format:: - use immediate base class only,
   1268     // in case immediate base modifies behavior later.
   1269     return DateFormat::format(obj, appendTo, posIter, status);
   1270 }
   1271 
   1272 inline UnicodeString&
   1273 SimpleDateFormat::format(UDate date,
   1274                          UnicodeString& appendTo,
   1275                          FieldPosition& fieldPosition) const {
   1276     // Don't use Format:: - use immediate base class only,
   1277     // in case immediate base modifies behavior later.
   1278     return DateFormat::format(date, appendTo, fieldPosition);
   1279 }
   1280 
   1281 inline UnicodeString&
   1282 SimpleDateFormat::format(UDate date,
   1283                          UnicodeString& appendTo,
   1284                          FieldPositionIterator* posIter,
   1285                          UErrorCode& status) const {
   1286     // Don't use Format:: - use immediate base class only,
   1287     // in case immediate base modifies behavior later.
   1288     return DateFormat::format(date, appendTo, posIter, status);
   1289 }
   1290 
   1291 inline UnicodeString&
   1292 SimpleDateFormat::format(UDate date, UnicodeString& appendTo) const {
   1293     return DateFormat::format(date, appendTo);
   1294 }
   1295 
   1296 U_NAMESPACE_END
   1297 
   1298 #endif /* #if !UCONFIG_NO_FORMATTING */
   1299 
   1300 #endif // _SMPDTFMT
   1301 //eof
   1302