1 // © 2016 and later: Unicode, Inc. and others. 
   2 // License & terms of use: http://www.unicode.org/copyright.html 
   4 * Copyright (C) 1997-2016, International Business Machines Corporation and 
   5 * others. All Rights Reserved. 
   6 ******************************************************************************* 
  10 * Modification History: 
  12 *   Date        Name        Description 
  13 *   02/19/97    aliu        Converted from java. 
  14 *   07/09/97    helena      Make ParsePosition into a class. 
  15 *   07/21/98    stephen     Added GMT_PLUS, GMT_MINUS 
  16 *                            Changed setTwoDigitStartDate to set2DigitYearStart 
  17 *                            Changed getTwoDigitStartDate to get2DigitYearStart 
  18 *                            Removed subParseLong 
  19 *                            Removed getZoneIndex (added in DateFormatSymbols) 
  20 *   06/14/99    stephen     Removed fgTimeZoneDataSuffix 
  21 *   10/14/99    aliu        Updated class doc to describe 2-digit year parsing 
  23 ******************************************************************************* 
  29 #include "unicode/utypes.h" 
  31 #if U_SHOW_CPLUSPLUS_API 
  35  * \brief C++ API: Format and parse dates in a language-independent manner. 
  38 #if !UCONFIG_NO_FORMATTING 
  40 #include "unicode/datefmt.h" 
  41 #include "unicode/udisplaycontext.h" 
  42 #include "unicode/tzfmt.h"  /* for UTimeZoneFormatTimeType */ 
  43 #include "unicode/brkiter.h" 
  47 class DateFormatSymbols
; 
  50 class FieldPositionHandler
; 
  52 class SharedNumberFormat
; 
  53 class SimpleDateFormatMutableNFs
; 
  54 class DateIntervalFormat
; 
  57 class LocalizedNumberFormatter
; 
  62  * SimpleDateFormat is a concrete class for formatting and parsing dates in a 
  63  * language-independent manner. It allows for formatting (millis -> text), 
  64  * parsing (text -> millis), and normalization. Formats/Parses a date or time, 
  65  * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970. 
  67  * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(), 
  68  * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than 
  69  * explicitly constructing an instance of SimpleDateFormat.  This way, the client 
  70  * is guaranteed to get an appropriate formatting pattern for whatever locale the 
  71  * program is running in.  However, if the client needs something more unusual than 
  72  * the default patterns in the locales, he can construct a SimpleDateFormat directly 
  73  * and give it an appropriate pattern (or use one of the factory methods on DateFormat 
  74  * and modify the pattern after the fact with toPattern() and applyPattern(). 
  76  * <p><strong>Date and Time Patterns:</strong></p> 
  78  * <p>Date and time formats are specified by <em>date and time pattern</em> strings. 
  79  * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved 
  80  * as pattern letters representing calendar fields. <code>SimpleDateFormat</code> supports 
  81  * the date and time formatting algorithm and pattern letters defined by 
  82  * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35 
  83  * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the 
  84  * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table">ICU 
  85  * User Guide</a>. The following pattern letters are currently available (note that the actual 
  86  * values depend on CLDR and may change from the examples shown here):</p> 
  91  *         <th style="text-align: center">Sym.</th> 
  92  *         <th style="text-align: center">No.</th> 
  94  *         <th>Description</th> 
  97  *         <th rowspan="3">era</th> 
  98  *         <td style="text-align: center" rowspan="3">G</td> 
  99  *         <td style="text-align: center">1..3</td> 
 101  *         <td rowspan="3">Era - Replaced with the Era string for the current date. One to three letters for the 
 102  *         abbreviated form, four letters for the long (wide) form, five for the narrow form.</td> 
 105  *         <td style="text-align: center">4</td> 
 106  *         <td>Anno Domini</td> 
 109  *         <td style="text-align: center">5</td> 
 113  *         <th rowspan="6">year</th> 
 114  *         <td style="text-align: center">y</td> 
 115  *         <td style="text-align: center">1..n</td> 
 117  *         <td>Year. Normally the length specifies the padding, but for two letters it also specifies the maximum 
 118  *         length. Example:<div align="center"> 
 120  *             <table border="1" cellpadding="2" cellspacing="0"> 
 123  *                     <th style="text-align: right">y</th> 
 124  *                     <th style="text-align: right">yy</th> 
 125  *                     <th style="text-align: right">yyy</th> 
 126  *                     <th style="text-align: right">yyyy</th> 
 127  *                     <th style="text-align: right">yyyyy</th> 
 131  *                     <td style="text-align: right">1</td> 
 132  *                     <td style="text-align: right">01</td> 
 133  *                     <td style="text-align: right">001</td> 
 134  *                     <td style="text-align: right">0001</td> 
 135  *                     <td style="text-align: right">00001</td> 
 139  *                     <td style="text-align: right">12</td> 
 140  *                     <td style="text-align: right">12</td> 
 141  *                     <td style="text-align: right">012</td> 
 142  *                     <td style="text-align: right">0012</td> 
 143  *                     <td style="text-align: right">00012</td> 
 147  *                     <td style="text-align: right">123</td> 
 148  *                     <td style="text-align: right">23</td> 
 149  *                     <td style="text-align: right">123</td> 
 150  *                     <td style="text-align: right">0123</td> 
 151  *                     <td style="text-align: right">00123</td> 
 155  *                     <td style="text-align: right">1234</td> 
 156  *                     <td style="text-align: right">34</td> 
 157  *                     <td style="text-align: right">1234</td> 
 158  *                     <td style="text-align: right">1234</td> 
 159  *                     <td style="text-align: right">01234</td> 
 163  *                     <td style="text-align: right">12345</td> 
 164  *                     <td style="text-align: right">45</td> 
 165  *                     <td style="text-align: right">12345</td> 
 166  *                     <td style="text-align: right">12345</td> 
 167  *                     <td style="text-align: right">12345</td> 
 174  *         <td style="text-align: center">Y</td> 
 175  *         <td style="text-align: center">1..n</td> 
 177  *         <td>Year (in "Week of Year" based calendars). Normally the length specifies the padding, 
 178  *         but for two letters it also specifies the maximum length. This year designation is used in ISO 
 179  *         year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems 
 180  *         where week date processing is desired. May not always be the same value as calendar year.</td> 
 183  *         <td style="text-align: center">u</td> 
 184  *         <td style="text-align: center">1..n</td> 
 186  *         <td>Extended year. This is a single number designating the year of this calendar system, encompassing 
 187  *         all supra-year fields. For example, for the Julian calendar system, year numbers are positive, with an 
 188  *         era of BCE or CE. An extended year value for the Julian calendar system assigns positive values to CE 
 189  *         years and negative values to BCE years, with 1 BCE being year 0.</td> 
 192  *         <td style="text-align: center" rowspan="3">U</td> 
 193  *         <td style="text-align: center">1..3</td> 
 194  *         <td>甲子</td> 
 195  *         <td rowspan="3">Cyclic year name. Calendars such as the Chinese lunar calendar (and related calendars) 
 196  *         and the Hindu calendars use 60-year cycles of year names. Use one through three letters for the abbreviated 
 197  *         name, four for the full (wide) name, or five for the narrow name (currently the data only provides abbreviated names, 
 198  *         which will be used for all requested name widths). If the calendar does not provide cyclic year name data, 
 199  *         or if the year value to be formatted is out of the range of years for which cyclic name data is provided, 
 200  *         then numeric formatting is used (behaves like 'y').</td> 
 203  *         <td style="text-align: center">4</td> 
 204  *         <td>(currently also 甲子)</td> 
 207  *         <td style="text-align: center">5</td> 
 208  *         <td>(currently also 甲子)</td> 
 211  *         <th rowspan="6">quarter</th> 
 212  *         <td rowspan="3" style="text-align: center">Q</td> 
 213  *         <td style="text-align: center">1..2</td> 
 215  *         <td rowspan="3">Quarter - Use one or two for the numerical quarter, three for the abbreviation, or four for the 
 216  *         full (wide) name (five for the narrow name is not yet supported).</td> 
 219  *         <td style="text-align: center">3</td> 
 223  *         <td style="text-align: center">4</td> 
 224  *         <td>2nd quarter</td> 
 227  *         <td rowspan="3" style="text-align: center">q</td> 
 228  *         <td style="text-align: center">1..2</td> 
 230  *         <td rowspan="3"><b>Stand-Alone</b> Quarter - Use one or two for the numerical quarter, three for the abbreviation, 
 231  *         or four for the full name (five for the narrow name is not yet supported).</td> 
 234  *         <td style="text-align: center">3</td> 
 238  *         <td style="text-align: center">4</td> 
 239  *         <td>2nd quarter</td> 
 242  *         <th rowspan="8">month</th> 
 243  *         <td rowspan="4" style="text-align: center">M</td> 
 244  *         <td style="text-align: center">1..2</td> 
 246  *         <td rowspan="4">Month - Use one or two for the numerical month, three for the abbreviation, four for 
 247  *         the full (wide) name, or five for the narrow name. With two ("MM"), the month number is zero-padded 
 248  *         if necessary (e.g. "08")</td> 
 251  *         <td style="text-align: center">3</td> 
 255  *         <td style="text-align: center">4</td> 
 259  *         <td style="text-align: center">5</td> 
 263  *         <td rowspan="4" style="text-align: center">L</td> 
 264  *         <td style="text-align: center">1..2</td> 
 266  *         <td rowspan="4"><b>Stand-Alone</b> Month - Use one or two for the numerical month, three for the abbreviation, 
 267  *         four for the full (wide) name, or 5 for the narrow name. With two ("LL"), the month number is zero-padded if 
 268  *         necessary (e.g. "08")</td> 
 271  *         <td style="text-align: center">3</td> 
 275  *         <td style="text-align: center">4</td> 
 279  *         <td style="text-align: center">5</td> 
 283  *         <th rowspan="2">week</th> 
 284  *         <td style="text-align: center">w</td> 
 285  *         <td style="text-align: center">1..2</td> 
 287  *         <td>Week of Year. Use "w" to show the minimum number of digits, or "ww" to always show two digits 
 288  *         (zero-padding if necessary, e.g. "08").</td> 
 291  *         <td style="text-align: center">W</td> 
 292  *         <td style="text-align: center">1</td> 
 294  *         <td>Week of Month</td> 
 297  *         <th rowspan="4">day</th> 
 298  *         <td style="text-align: center">d</td> 
 299  *         <td style="text-align: center">1..2</td> 
 301  *         <td>Date - Day of the month. Use "d" to show the minimum number of digits, or "dd" to always show 
 302  *         two digits (zero-padding if necessary, e.g. "08").</td> 
 305  *         <td style="text-align: center">D</td> 
 306  *         <td style="text-align: center">1..3</td> 
 308  *         <td>Day of year</td> 
 311  *         <td style="text-align: center">F</td> 
 312  *         <td style="text-align: center">1</td> 
 314  *         <td>Day of Week in Month. The example is for the 2nd Wed in July</td> 
 317  *         <td style="text-align: center">g</td> 
 318  *         <td style="text-align: center">1..n</td> 
 320  *         <td>Modified Julian day. This is different from the conventional Julian day number in two regards. 
 321  *         First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; 
 322  *         that is, it depends on the local time zone. It can be thought of as a single number that encompasses 
 323  *         all the date-related fields.</td> 
 326  *         <th rowspan="14">week<br> 
 328  *         <td rowspan="4" style="text-align: center">E</td> 
 329  *         <td style="text-align: center">1..3</td> 
 331  *         <td rowspan="4">Day of week - Use one through three letters for the short day, four for the full (wide) name, 
 332  *         five for the narrow name, or six for the short name.</td> 
 335  *         <td style="text-align: center">4</td> 
 339  *         <td style="text-align: center">5</td> 
 343  *         <td style="text-align: center">6</td> 
 347  *         <td rowspan="5" style="text-align: center">e</td> 
 348  *         <td style="text-align: center">1..2</td> 
 350  *         <td rowspan="5">Local day of week. Same as E except adds a numeric value that will depend on the local 
 351  *         starting day of the week, using one or two letters. For this example, Monday is the first day of the week.</td> 
 354  *         <td style="text-align: center">3</td> 
 358  *         <td style="text-align: center">4</td> 
 362  *         <td style="text-align: center">5</td> 
 366  *         <td style="text-align: center">6</td> 
 370  *         <td rowspan="5" style="text-align: center">c</td> 
 371  *         <td style="text-align: center">1</td> 
 373  *         <td rowspan="5"><b>Stand-Alone</b> local day of week - Use one letter for the local numeric value (same 
 374  *         as 'e'), three for the short day, four for the full (wide) name, five for the narrow name, or six for 
 375  *         the short name.</td> 
 378  *         <td style="text-align: center">3</td> 
 382  *         <td style="text-align: center">4</td> 
 386  *         <td style="text-align: center">5</td> 
 390  *         <td style="text-align: center">6</td> 
 395  *         <td style="text-align: center">a</td> 
 396  *         <td style="text-align: center">1</td> 
 401  *         <th rowspan="4">hour</th> 
 402  *         <td style="text-align: center">h</td> 
 403  *         <td style="text-align: center">1..2</td> 
 405  *         <td>Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern 
 406  *         generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match 
 407  *         a 24-hour-cycle format (H or k). Use hh for zero padding.</td> 
 410  *         <td style="text-align: center">H</td> 
 411  *         <td style="text-align: center">1..2</td> 
 413  *         <td>Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern 
 414  *         generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 
 415  *         12-hour-cycle format (h or K). Use HH for zero padding.</td> 
 418  *         <td style="text-align: center">K</td> 
 419  *         <td style="text-align: center">1..2</td> 
 421  *         <td>Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding.</td> 
 424  *         <td style="text-align: center">k</td> 
 425  *         <td style="text-align: center">1..2</td> 
 427  *         <td>Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding.</td> 
 431  *         <td style="text-align: center">m</td> 
 432  *         <td style="text-align: center">1..2</td> 
 434  *         <td>Minute. Use "m" to show the minimum number of digits, or "mm" to always show two digits 
 435  *         (zero-padding if necessary, e.g. "08").</td> 
 438  *         <th rowspan="3">second</th> 
 439  *         <td style="text-align: center">s</td> 
 440  *         <td style="text-align: center">1..2</td> 
 442  *         <td>Second. Use "s" to show the minimum number of digits, or "ss" to always show two digits 
 443  *         (zero-padding if necessary, e.g. "08").</td> 
 446  *         <td style="text-align: center">S</td> 
 447  *         <td style="text-align: center">1..n</td> 
 449  *         <td>Fractional Second - truncates (like other time fields) to the count of letters when formatting. 
 450  *         Appends zeros if more than 3 letters specified. Truncates at three significant digits when parsing. 
 451  *         (example shows display using pattern SSSS for seconds value 12.34567)</td> 
 454  *         <td style="text-align: center">A</td> 
 455  *         <td style="text-align: center">1..n</td> 
 457  *         <td>Milliseconds in day. This field behaves <i>exactly</i> like a composite of all time-related fields, 
 458  *         not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition 
 459  *         days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This 
 460  *         reflects the fact that is must be combined with the offset field to obtain a unique local time value.</td> 
 463  *         <th rowspan="23">zone</th> 
 464  *         <td rowspan="2" style="text-align: center">z</td> 
 465  *         <td style="text-align: center">1..3</td> 
 467  *         <td>The <i>short specific non-location format</i>. 
 468  *         Where that is unavailable, falls back to the <i>short localized GMT format</i> ("O").</td> 
 471  *         <td style="text-align: center">4</td> 
 472  *         <td>Pacific Daylight Time</td> 
 473  *         <td>The <i>long specific non-location format</i>. 
 474  *         Where that is unavailable, falls back to the <i>long localized GMT format</i> ("OOOO").</td> 
 477  *         <td rowspan="3" style="text-align: center">Z</td> 
 478  *         <td style="text-align: center">1..3</td> 
 480  *         <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields. 
 481  *         The format is equivalent to RFC 822 zone format (when optional seconds field is absent). 
 482  *         This is equivalent to the "xxxx" specifier.</td> 
 485  *         <td style="text-align: center">4</td> 
 487  *         <td>The <i>long localized GMT format</i>. 
 488  *         This is equivalent to the "OOOO" specifier.</td> 
 491  *         <td style="text-align: center">5</td> 
 494  *         <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields. 
 495  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0. 
 496  *         This is equivalent to the "XXXXX" specifier.</td> 
 499  *         <td rowspan="2" style="text-align: center">O</td> 
 500  *         <td style="text-align: center">1</td> 
 502  *         <td>The <i>short localized GMT format</i>.</td> 
 505  *         <td style="text-align: center">4</td> 
 507  *         <td>The <i>long localized GMT format</i>.</td> 
 510  *         <td rowspan="2" style="text-align: center">v</td> 
 511  *         <td style="text-align: center">1</td> 
 513  *         <td>The <i>short generic non-location format</i>. 
 514  *         Where that is unavailable, falls back to the <i>generic location format</i> ("VVVV"), 
 515  *         then the <i>short localized GMT format</i> as the final fallback.</td> 
 518  *         <td style="text-align: center">4</td> 
 519  *         <td>Pacific Time</td> 
 520  *         <td>The <i>long generic non-location format</i>. 
 521  *         Where that is unavailable, falls back to <i>generic location format</i> ("VVVV"). 
 524  *         <td rowspan="4" style="text-align: center">V</td> 
 525  *         <td style="text-align: center">1</td> 
 527  *         <td>The short time zone ID. 
 528  *         Where that is unavailable, the special short time zone ID <i>unk</i> (Unknown Zone) is used.<br> 
 529  *         <i><b>Note</b>: This specifier was originally used for a variant of the short specific non-location format, 
 530  *         but it was deprecated in the later version of the LDML specification. In CLDR 23/ICU 51, the definition of 
 531  *         the specifier was changed to designate a short time zone ID.</i></td> 
 534  *         <td style="text-align: center">2</td> 
 535  *         <td>America/Los_Angeles</td> 
 536  *         <td>The long time zone ID.</td> 
 539  *         <td style="text-align: center">3</td> 
 540  *         <td>Los Angeles</td> 
 541  *         <td>The exemplar city (location) for the time zone. 
 542  *         Where that is unavailable, the localized exemplar city name for the special zone <i>Etc/Unknown</i> is used 
 543  *         as the fallback (for example, "Unknown City"). </td> 
 546  *         <td style="text-align: center">4</td> 
 547  *         <td>Los Angeles Time</td> 
 548  *         <td>The <i>generic location format</i>. 
 549  *         Where that is unavailable, falls back to the <i>long localized GMT format</i> ("OOOO"; 
 550  *         Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.)<br> 
 551  *         This is especially useful when presenting possible timezone choices for user selection, 
 552  *         since the naming is more uniform than the "v" format.</td> 
 555  *         <td rowspan="5" style="text-align: center">X</td> 
 556  *         <td style="text-align: center">1</td> 
 560  *         <td>The <i>ISO8601 basic format</i> with hours field and optional minutes field. 
 561  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td> 
 564  *         <td style="text-align: center">2</td> 
 567  *         <td>The <i>ISO8601 basic format</i> with hours and minutes fields. 
 568  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td> 
 571  *         <td style="text-align: center">3</td> 
 574  *         <td>The <i>ISO8601 extended format</i> with hours and minutes fields. 
 575  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td> 
 578  *         <td style="text-align: center">4</td> 
 582  *         <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields. 
 583  *         (Note: The seconds field is not supported by the ISO8601 specification.) 
 584  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td> 
 587  *         <td style="text-align: center">5</td> 
 591  *         <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields. 
 592  *         (Note: The seconds field is not supported by the ISO8601 specification.) 
 593  *         The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td> 
 596  *         <td rowspan="5" style="text-align: center">x</td> 
 597  *         <td style="text-align: center">1</td> 
 600  *         <td>The <i>ISO8601 basic format</i> with hours field and optional minutes field.</td> 
 603  *         <td style="text-align: center">2</td> 
 605  *         <td>The <i>ISO8601 basic format</i> with hours and minutes fields.</td> 
 608  *         <td style="text-align: center">3</td> 
 610  *         <td>The <i>ISO8601 extended format</i> with hours and minutes fields.</td> 
 613  *         <td style="text-align: center">4</td> 
 616  *         <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields. 
 617  *         (Note: The seconds field is not supported by the ISO8601 specification.)</td> 
 620  *         <td style="text-align: center">5</td> 
 623  *         <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields. 
 624  *         (Note: The seconds field is not supported by the ISO8601 specification.)</td> 
 629  * Any characters in the pattern that are not in the ranges of ['a'..'z'] and 
 630  * ['A'..'Z'] will be treated as quoted text. For instance, characters 
 631  * like ':', '.', ' ', '#' and '@' will appear in the resulting time text 
 632  * even they are not embraced within single quotes. 
 634  * A pattern containing any invalid pattern letter will result in a failing 
 635  * UErrorCode result during formatting or parsing. 
 637  * Examples using the US locale: 
 640  *    Format Pattern                         Result 
 641  *    --------------                         ------- 
 642  *    "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->>  1996.07.10 AD at 15:08:56 Pacific Time 
 643  *    "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96 
 644  *    "h:mm a"                          ->>  12:08 PM 
 645  *    "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time 
 646  *    "K:mm a, vvv"                     ->>  0:00 PM, PT 
 647  *    "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM 
 653  *     UErrorCode success = U_ZERO_ERROR; 
 654  *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST"); 
 655  *     pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000); 
 656  *     pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000); 
 658  *     // Format the current time. 
 659  *     SimpleDateFormat* formatter 
 660  *         = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success ); 
 661  *     GregorianCalendar cal(success); 
 662  *     UDate currentTime_1 = cal.getTime(success); 
 663  *     FieldPosition fp(FieldPosition::DONT_CARE); 
 664  *     UnicodeString dateString; 
 665  *     formatter->format( currentTime_1, dateString, fp ); 
 666  *     cout << "result: " << dateString << endl; 
 668  *     // Parse the previous string back into a Date. 
 669  *     ParsePosition pp(0); 
 670  *     UDate currentTime_2 = formatter->parse(dateString, pp ); 
 673  * In the above example, the time value "currentTime_2" obtained from parsing 
 674  * will be equal to currentTime_1. However, they may not be equal if the am/pm 
 675  * marker 'a' is left out from the format pattern while the "hour in am/pm" 
 676  * pattern symbol is used. This information loss can happen when formatting the 
 680  * When parsing a date string using the abbreviated year pattern ("y" or "yy"), 
 681  * SimpleDateFormat must interpret the abbreviated year 
 682  * relative to some century.  It does this by adjusting dates to be 
 683  * within 80 years before and 20 years after the time the SimpleDateFormat 
 684  * instance is created. For example, using a pattern of "MM/dd/yy" and a 
 685  * SimpleDateFormat instance created on Jan 1, 1997,  the string 
 686  * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" 
 687  * would be interpreted as May 4, 1964. 
 688  * During parsing, only strings consisting of exactly two digits, as defined by 
 689  * <code>Unicode::isDigit()</code>, will be parsed into the default century. 
 690  * Any other numeric string, such as a one digit string, a three or more digit 
 691  * string, or a two digit string that isn't all digits (for example, "-1"), is 
 692  * interpreted literally.  So "01/02/3" or "01/02/003" are parsed (for the 
 693  * Gregorian calendar), using the same pattern, as Jan 2, 3 AD.  Likewise (but 
 694  * only in lenient parse mode, the default) "01/02/-3" is parsed as Jan 2, 4 BC. 
 697  * If the year pattern has more than two 'y' characters, the year is 
 698  * interpreted literally, regardless of the number of digits.  So using the 
 699  * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D. 
 702  * When numeric fields abut one another directly, with no intervening delimiter 
 703  * characters, they constitute a run of abutting numeric fields.  Such runs are 
 704  * parsed specially.  For example, the format "HHmmss" parses the input text 
 705  * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to 
 706  * parse "1234".  In other words, the leftmost field of the run is flexible, 
 707  * while the others keep a fixed width.  If the parse fails anywhere in the run, 
 708  * then the leftmost field is shortened by one character, and the entire run is 
 709  * parsed again. This is repeated until either the parse succeeds or the 
 710  * leftmost field is one character in length.  If the parse still fails at that 
 711  * point, the parse of the run fails. 
 714  * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or 
 717  * The calendar defines what is the first day of the week, the first week of the 
 718  * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone. 
 719  * There is one common number format to handle all the numbers; the digit count 
 720  * is handled programmatically according to the pattern. 
 722  * <p><em>User subclasses are not supported.</em> While clients may write 
 723  * subclasses, such code will not necessarily work and will not be 
 724  * guaranteed to work stably from release to release. 
 726 class U_I18N_API SimpleDateFormat
: public DateFormat 
{ 
 729      * Construct a SimpleDateFormat using the default pattern for the default 
 732      * [Note:] Not all locales support SimpleDateFormat; for full generality, 
 733      * use the factory methods in the DateFormat class. 
 734      * @param status    Output param set to success/failure code. 
 737     SimpleDateFormat(UErrorCode
& status
); 
 740      * Construct a SimpleDateFormat using the given pattern and the default locale. 
 741      * The locale is used to obtain the symbols used in formatting (e.g., the 
 742      * names of the months), but not to provide the pattern. 
 744      * [Note:] Not all locales support SimpleDateFormat; for full generality, 
 745      * use the factory methods in the DateFormat class. 
 746      * @param pattern    the pattern for the format. 
 747      * @param status     Output param set to success/failure code. 
 750     SimpleDateFormat(const UnicodeString
& pattern
, 
 754      * Construct a SimpleDateFormat using the given pattern, numbering system override, and the default locale. 
 755      * The locale is used to obtain the symbols used in formatting (e.g., the 
 756      * names of the months), but not to provide the pattern. 
 758      * A numbering system override is a string containing either the name of a known numbering system, 
 759      * or a set of field and numbering system pairs that specify which fields are to be formattied with 
 760      * the alternate numbering system.  For example, to specify that all numeric fields in the specified 
 761      * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override 
 762      * as "thai".  To specify that just the year portion of the date be formatted using Hebrew numbering, 
 763      * use the override string "y=hebrew".  Numbering system overrides can be combined using a semi-colon 
 764      * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc. 
 767      * [Note:] Not all locales support SimpleDateFormat; for full generality, 
 768      * use the factory methods in the DateFormat class. 
 769      * @param pattern    the pattern for the format. 
 770      * @param override   the override string. 
 771      * @param status     Output param set to success/failure code. 
 774     SimpleDateFormat(const UnicodeString
& pattern
, 
 775                      const UnicodeString
& override
, 
 779      * Construct a SimpleDateFormat using the given pattern and locale. 
 780      * The locale is used to obtain the symbols used in formatting (e.g., the 
 781      * names of the months), but not to provide the pattern. 
 783      * [Note:] Not all locales support SimpleDateFormat; for full generality, 
 784      * use the factory methods in the DateFormat class. 
 785      * @param pattern    the pattern for the format. 
 786      * @param locale     the given locale. 
 787      * @param status     Output param set to success/failure code. 
 790     SimpleDateFormat(const UnicodeString
& pattern
, 
 791                      const Locale
& locale
, 
 795      * Construct a SimpleDateFormat using the given pattern, numbering system override, and locale. 
 796      * The locale is used to obtain the symbols used in formatting (e.g., the 
 797      * names of the months), but not to provide the pattern. 
 799      * A numbering system override is a string containing either the name of a known numbering system, 
 800      * or a set of field and numbering system pairs that specify which fields are to be formattied with 
 801      * the alternate numbering system.  For example, to specify that all numeric fields in the specified 
 802      * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override 
 803      * as "thai".  To specify that just the year portion of the date be formatted using Hebrew numbering, 
 804      * use the override string "y=hebrew".  Numbering system overrides can be combined using a semi-colon 
 805      * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc. 
 807      * [Note:] Not all locales support SimpleDateFormat; for full generality, 
 808      * use the factory methods in the DateFormat class. 
 809      * @param pattern    the pattern for the format. 
 810      * @param override   the numbering system override. 
 811      * @param locale     the given locale. 
 812      * @param status     Output param set to success/failure code. 
 815     SimpleDateFormat(const UnicodeString
& pattern
, 
 816                      const UnicodeString
& override
, 
 817                      const Locale
& locale
, 
 821      * Construct a SimpleDateFormat using the given pattern and locale-specific 
 822      * symbol data.  The formatter takes ownership of the DateFormatSymbols object; 
 823      * the caller is no longer responsible for deleting it. 
 824      * @param pattern           the given pattern for the format. 
 825      * @param formatDataToAdopt the symbols to be adopted. 
 826      * @param status            Output param set to success/faulure code. 
 829     SimpleDateFormat(const UnicodeString
& pattern
, 
 830                      DateFormatSymbols
* formatDataToAdopt
, 
 834      * Construct a SimpleDateFormat using the given pattern and locale-specific 
 835      * symbol data.  The DateFormatSymbols object is NOT adopted; the caller 
 836      * remains responsible for deleting it. 
 837      * @param pattern           the given pattern for the format. 
 838      * @param formatData        the formatting symbols to be use. 
 839      * @param status            Output param set to success/faulure code. 
 842     SimpleDateFormat(const UnicodeString
& pattern
, 
 843                      const DateFormatSymbols
& formatData
, 
 850     SimpleDateFormat(const SimpleDateFormat
&); 
 853      * Assignment operator. 
 856     SimpleDateFormat
& operator=(const SimpleDateFormat
&); 
 862     virtual ~SimpleDateFormat(); 
 865      * Clone this Format object polymorphically. The caller owns the result and 
 866      * should delete it when done. 
 867      * @return    A copy of the object. 
 870     virtual SimpleDateFormat
* clone() const; 
 873      * Return true if the given Format objects are semantically equal. Objects 
 874      * of different subclasses are considered unequal. 
 875      * @param other    the object to be compared with. 
 876      * @return         true if the given Format objects are semantically equal. 
 879     virtual UBool 
operator==(const Format
& other
) const; 
 882     using DateFormat::format
; 
 885      * Format a date or time, which is the standard millis since 24:00 GMT, Jan 
 886      * 1, 1970. Overrides DateFormat pure virtual method. 
 888      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->> 
 889      * 1996.07.10 AD at 15:08:56 PDT 
 891      * @param cal       Calendar set to the date and time to be formatted 
 892      *                  into a date/time string. 
 893      * @param appendTo  Output parameter to receive result. 
 894      *                  Result is appended to existing contents. 
 895      * @param pos       The formatting position. On input: an alignment field, 
 896      *                  if desired. On output: the offsets of the alignment field. 
 897      * @return          Reference to 'appendTo' parameter. 
 900     virtual UnicodeString
& format(  Calendar
& cal
, 
 901                                     UnicodeString
& appendTo
, 
 902                                     FieldPosition
& pos
) const; 
 905      * Format a date or time, which is the standard millis since 24:00 GMT, Jan 
 906      * 1, 1970. Overrides DateFormat pure virtual method. 
 908      * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->> 
 909      * 1996.07.10 AD at 15:08:56 PDT 
 911      * @param cal       Calendar set to the date and time to be formatted 
 912      *                  into a date/time string. 
 913      * @param appendTo  Output parameter to receive result. 
 914      *                  Result is appended to existing contents. 
 915      * @param posIter   On return, can be used to iterate over positions 
 916      *                  of fields generated by this format call.  Field values 
 917      *                  are defined in UDateFormatField. 
 918      * @param status    Input/output param set to success/failure code. 
 919      * @return          Reference to 'appendTo' parameter. 
 922     virtual UnicodeString
& format(  Calendar
& cal
, 
 923                                     UnicodeString
& appendTo
, 
 924                                     FieldPositionIterator
* posIter
, 
 925                                     UErrorCode
& status
) const; 
 927     using DateFormat::parse
; 
 930      * Parse a date/time string beginning at the given parse position. For 
 931      * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date 
 932      * that is equivalent to Date(837039928046). 
 934      * By default, parsing is lenient: If the input is not in the form used by 
 935      * this object's format method but can still be parsed as a date, then the 
 936      * parse succeeds. Clients may insist on strict adherence to the format by 
 937      * calling setLenient(false). 
 938      * @see DateFormat::setLenient(boolean) 
 940      * @param text  The date/time string to be parsed 
 941      * @param cal   A Calendar set on input to the date and time to be used for 
 942      *              missing values in the date/time string being parsed, and set 
 943      *              on output to the parsed date/time. When the calendar type is 
 944      *              different from the internal calendar held by this SimpleDateFormat 
 945      *              instance, the internal calendar will be cloned to a work 
 946      *              calendar set to the same milliseconds and time zone as the 
 947      *              cal parameter, field values will be parsed based on the work 
 948      *              calendar, then the result (milliseconds and time zone) will 
 949      *              be set in this calendar. 
 950      * @param pos   On input, the position at which to start parsing; on 
 951      *              output, the position at which parsing terminated, or the 
 952      *              start position if the parse failed. 
 955     virtual void parse( const UnicodeString
& text
, 
 957                         ParsePosition
& pos
) const; 
 961      * Set the start UDate used to interpret two-digit year strings. 
 962      * When dates are parsed having 2-digit year strings, they are placed within 
 963      * a assumed range of 100 years starting on the two digit start date.  For 
 964      * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or 
 965      * some other year.  SimpleDateFormat chooses a year so that the resultant 
 966      * date is on or after the two digit start date and within 100 years of the 
 967      * two digit start date. 
 969      * By default, the two digit start date is set to 80 years before the current 
 970      * time at which a SimpleDateFormat object is created. 
 971      * @param d      start UDate used to interpret two-digit year strings. 
 972      * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with 
 973      *               an error value if there was a parse error. 
 976     virtual void set2DigitYearStart(UDate d
, UErrorCode
& status
); 
 979      * Get the start UDate used to interpret two-digit year strings. 
 980      * When dates are parsed having 2-digit year strings, they are placed within 
 981      * a assumed range of 100 years starting on the two digit start date.  For 
 982      * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or 
 983      * some other year.  SimpleDateFormat chooses a year so that the resultant 
 984      * date is on or after the two digit start date and within 100 years of the 
 985      * two digit start date. 
 987      * By default, the two digit start date is set to 80 years before the current 
 988      * time at which a SimpleDateFormat object is created. 
 989      * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with 
 990      *               an error value if there was a parse error. 
 993     UDate 
get2DigitYearStart(UErrorCode
& status
) const; 
 996      * Return a pattern string describing this date format. 
 997      * @param result Output param to receive the pattern. 
 998      * @return       A reference to 'result'. 
1001     virtual UnicodeString
& toPattern(UnicodeString
& result
) const; 
1004      * Return a localized pattern string describing this date format. 
1005      * In most cases, this will return the same thing as toPattern(), 
1006      * but a locale can specify characters to use in pattern descriptions 
1007      * in place of the ones described in this class's class documentation. 
1008      * (Presumably, letters that would be more mnemonic in that locale's 
1009      * language.)  This function would produce a pattern using those 
1012      * <b>Note:</b> This implementation depends on DateFormatSymbols::getLocalPatternChars() 
1013      * to get localized format pattern characters. ICU does not include 
1014      * localized pattern character data, therefore, unless user sets localized 
1015      * pattern characters manually, this method returns the same result as 
1018      * @param result    Receives the localized pattern. 
1019      * @param status    Output param set to success/failure code on 
1020      *                  exit. If the pattern is invalid, this will be 
1021      *                  set to a failure result. 
1022      * @return          A reference to 'result'. 
1025     virtual UnicodeString
& toLocalizedPattern(UnicodeString
& result
, 
1026                                               UErrorCode
& status
) const; 
1029      * Apply the given unlocalized pattern string to this date format. 
1030      * (i.e., after this call, this formatter will format dates according to 
1033      * @param pattern   The pattern to be applied. 
1036     virtual void applyPattern(const UnicodeString
& pattern
); 
1039      * Apply the given localized pattern string to this date format. 
1040      * (see toLocalizedPattern() for more information on localized patterns.) 
1042      * @param pattern   The localized pattern to be applied. 
1043      * @param status    Output param set to success/failure code on 
1044      *                  exit. If the pattern is invalid, this will be 
1045      *                  set to a failure result. 
1048     virtual void applyLocalizedPattern(const UnicodeString
& pattern
, 
1049                                        UErrorCode
& status
); 
1052      * Gets the date/time formatting symbols (this is an object carrying 
1053      * the various strings and other symbols used in formatting: e.g., month 
1054      * names and abbreviations, time zone names, AM/PM strings, etc.) 
1055      * @return a copy of the date-time formatting data associated 
1056      * with this date-time formatter. 
1059     virtual const DateFormatSymbols
* getDateFormatSymbols(void) const; 
1062      * Set the date/time formatting symbols.  The caller no longer owns the 
1063      * DateFormatSymbols object and should not delete it after making this call. 
1064      * @param newFormatSymbols the given date-time formatting symbols to copy. 
1067     virtual void adoptDateFormatSymbols(DateFormatSymbols
* newFormatSymbols
); 
1070      * Set the date/time formatting data. 
1071      * @param newFormatSymbols the given date-time formatting symbols to copy. 
1074     virtual void setDateFormatSymbols(const DateFormatSymbols
& newFormatSymbols
); 
1077      * Return the class ID for this class. This is useful only for comparing to 
1078      * a return value from getDynamicClassID(). For example: 
1080      * .   Base* polymorphic_pointer = createPolymorphicObject(); 
1081      * .   if (polymorphic_pointer->getDynamicClassID() == 
1082      * .       erived::getStaticClassID()) ... 
1084      * @return          The class ID for all objects of this class. 
1087     static UClassID U_EXPORT2 
getStaticClassID(void); 
1090      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This 
1091      * method is to implement a simple version of RTTI, since not all C++ 
1092      * compilers support genuine RTTI. Polymorphic operator==() and clone() 
1093      * methods call this method. 
1095      * @return          The class ID for this object. All objects of a 
1096      *                  given class have the same class ID.  Objects of 
1097      *                  other classes have different class IDs. 
1100     virtual UClassID 
getDynamicClassID(void) const; 
1103      * Set the calendar to be used by this date format. Initially, the default 
1104      * calendar for the specified or default locale is used.  The caller should 
1105      * not delete the Calendar object after it is adopted by this call. 
1106      * Adopting a new calendar will change to the default symbols. 
1108      * @param calendarToAdopt    Calendar object to be adopted. 
1111     virtual void adoptCalendar(Calendar
* calendarToAdopt
); 
1113     /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since they are virtual */ 
1115      * Sets the TimeZoneFormat to be used by this date/time formatter. 
1116      * The caller should not delete the TimeZoneFormat object after 
1117      * it is adopted by this call. 
1118      * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted. 
1119      * @internal ICU 49 technology preview 
1121     virtual void adoptTimeZoneFormat(TimeZoneFormat
* timeZoneFormatToAdopt
); 
1124      * Sets the TimeZoneFormat to be used by this date/time formatter. 
1125      * @param newTimeZoneFormat The TimeZoneFormat object to copy. 
1126      * @internal ICU 49 technology preview 
1128     virtual void setTimeZoneFormat(const TimeZoneFormat
& newTimeZoneFormat
); 
1131      * Gets the time zone format object associated with this date/time formatter. 
1132      * @return the time zone format associated with this date/time formatter. 
1133      * @internal ICU 49 technology preview 
1135     virtual const TimeZoneFormat
* getTimeZoneFormat(void) const; 
1138      * Set a particular UDisplayContext value in the formatter, such as 
1139      * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see 
1141      * @param value The UDisplayContext value to set. 
1142      * @param status Input/output status. If at entry this indicates a failure 
1143      *               status, the function will do nothing; otherwise this will be 
1144      *               updated with any new status from the function. 
1147     virtual void setContext(UDisplayContext value
, UErrorCode
& status
); 
1150      * Overrides base class method and 
1151      * This method clears per field NumberFormat instances 
1152      * previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFormat*, UErrorCode)} 
1153      * @param formatToAdopt the NumbeferFormat used 
1156     void adoptNumberFormat(NumberFormat 
*formatToAdopt
); 
1159      * Allow the user to set the NumberFormat for several fields 
1160      * It can be a single field like: "y"(year) or "M"(month) 
1161      * It can be several field combined together: "yM"(year and month) 
1163      * 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy") 
1164      * If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field) 
1165      * Per field NumberFormat can also be cleared in {@see DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)} 
1167      * @param fields  the fields to override(like y) 
1168      * @param formatToAdopt the NumbeferFormat used 
1169      * @param status  Receives a status code, which will be U_ZERO_ERROR 
1170      *                if the operation succeeds. 
1173     void adoptNumberFormat(const UnicodeString
& fields
, NumberFormat 
*formatToAdopt
, UErrorCode 
&status
); 
1176      * Get the numbering system to be used for a particular field. 
1177      * @param field The UDateFormatField to get 
1180     const NumberFormat 
* getNumberFormatForField(char16_t field
) const; 
1182 #ifndef U_HIDE_INTERNAL_API 
1184      * This is for ICU internal use only. Please do not use. 
1185      * Check whether the 'field' is smaller than all the fields covered in 
1186      * pattern, return TRUE if it is. The sequence of calendar field, 
1187      * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... 
1188      * @param field    the calendar field need to check against 
1189      * @return         TRUE if the 'field' is smaller than all the fields 
1190      *                 covered in pattern. FALSE otherwise. 
1193     UBool 
isFieldUnitIgnored(UCalendarDateFields field
) const; 
1197      * This is for ICU internal use only. Please do not use. 
1198      * Check whether the 'field' is smaller than all the fields covered in 
1199      * pattern, return TRUE if it is. The sequence of calendar field, 
1200      * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... 
1201      * @param pattern  the pattern to check against 
1202      * @param field    the calendar field need to check against 
1203      * @return         TRUE if the 'field' is smaller than all the fields 
1204      *                 covered in pattern. FALSE otherwise. 
1207     static UBool 
isFieldUnitIgnored(const UnicodeString
& pattern
, 
1208                                     UCalendarDateFields field
); 
1211      * This is for ICU internal use only. Please do not use. 
1212      * Get the locale of this simple date formatter. 
1213      * It is used in DateIntervalFormat. 
1215      * @return   locale in this simple date formatter 
1218     const Locale
& getSmpFmtLocale(void) const; 
1222      * This is for ICU internal use only. Please do not use. 
1223      * Get the capitalization break iterator of this simple date formatter. 
1224      * Should be cloned before using it. 
1225      * It is used in udat. 
1227      * @return   capitalization break iterator 
1230     BreakIterator
* getCapitalizationBrkIter(void) const; 
1231 #endif  /* U_HIDE_INTERNAL_API */ 
1234     friend class DateFormat
; 
1235     friend class DateIntervalFormat
; 
1237     void initializeDefaultCentury(void); 
1239     void initializeBooleanAttributes(void); 
1241     SimpleDateFormat(); // default constructor not implemented 
1244      * Used by the DateFormat factory methods to construct a SimpleDateFormat. 
1245      * @param timeStyle the time style. 
1246      * @param dateStyle the date style. 
1247      * @param locale    the given locale. 
1248      * @param status    Output param set to success/failure code on 
1251     SimpleDateFormat(EStyle timeStyle
, EStyle dateStyle
, const Locale
& locale
, UErrorCode
& status
); 
1254      * Construct a SimpleDateFormat for the given locale.  If no resource data 
1255      * is available, create an object of last resort, using hard-coded strings. 
1256      * This is an internal method, called by DateFormat.  It should never fail. 
1257      * @param locale    the given locale. 
1258      * @param status    Output param set to success/failure code on 
1261     SimpleDateFormat(const Locale
& locale
, UErrorCode
& status
); // Use default pattern 
1264      * Hook called by format(... FieldPosition& ...) and format(...FieldPositionIterator&...) 
1266     UnicodeString
& _format(Calendar
& cal
, UnicodeString
& appendTo
, FieldPositionHandler
& handler
, UErrorCode
& status
) const; 
1269      * Called by format() to format a single field. 
1271      * @param appendTo  Output parameter to receive result. 
1272      *                  Result is appended to existing contents. 
1273      * @param ch        The format character we encountered in the pattern. 
1274      * @param count     Number of characters in the current pattern symbol (e.g., 
1275      *                  "yyyy" in the pattern would result in a call to this function 
1276      *                  with ch equal to 'y' and count equal to 4) 
1277      * @param capitalizationContext Capitalization context for this date format. 
1278      * @param fieldNum  Zero-based numbering of current field within the overall format. 
1279      * @param handler   Records information about field positions. 
1280      * @param cal       Calendar to use 
1281      * @param status    Receives a status code, which will be U_ZERO_ERROR if the operation 
1284     void subFormat(UnicodeString 
&appendTo
, 
1287                    UDisplayContext capitalizationContext
, 
1289                    FieldPositionHandler
& handler
, 
1291                    UErrorCode
& status
) const; // in case of illegal argument 
1294      * Used by subFormat() to format a numeric value. 
1295      * Appends to toAppendTo a string representation of "value" 
1296      * having a number of digits between "minDigits" and 
1297      * "maxDigits".  Uses the DateFormat's NumberFormat. 
1299      * @param currentNumberFormat 
1300      * @param appendTo  Output parameter to receive result. 
1301      *                  Formatted number is appended to existing contents. 
1302      * @param value     Value to format. 
1303      * @param minDigits Minimum number of digits the result should have 
1304      * @param maxDigits Maximum number of digits the result should have 
1306     void zeroPaddingNumber(const NumberFormat 
*currentNumberFormat
, 
1307                            UnicodeString 
&appendTo
, 
1310                            int32_t maxDigits
) const; 
1313      * Return true if the given format character, occuring count 
1314      * times, represents a numeric field. 
1316     static UBool 
isNumeric(char16_t formatChar
, int32_t count
); 
1319      * Returns TRUE if the patternOffset is at the start of a numeric field. 
1321     static UBool 
isAtNumericField(const UnicodeString 
&pattern
, int32_t patternOffset
); 
1324      * Returns TRUE if the patternOffset is right after a non-numeric field. 
1326     static UBool 
isAfterNonNumericField(const UnicodeString 
&pattern
, int32_t patternOffset
); 
1329      * initializes fCalendar from parameters.  Returns fCalendar as a convenience. 
1330      * @param adoptZone  Zone to be adopted, or NULL for TimeZone::createDefault(). 
1331      * @param locale Locale of the calendar 
1332      * @param status Error code 
1333      * @return the newly constructed fCalendar 
1335     Calendar 
*initializeCalendar(TimeZone
* adoptZone
, const Locale
& locale
, UErrorCode
& status
); 
1338      * Called by several of the constructors to load pattern data and formatting symbols 
1339      * out of a resource bundle and initialize the locale based on it. 
1340      * @param timeStyle     The time style, as passed to DateFormat::createDateInstance(). 
1341      * @param dateStyle     The date style, as passed to DateFormat::createTimeInstance(). 
1342      * @param locale        The locale to load the patterns from. 
1343      * @param status        Filled in with an error code if loading the data from the 
1346     void construct(EStyle timeStyle
, EStyle dateStyle
, const Locale
& locale
, UErrorCode
& status
); 
1348     UnicodeString 
getPatternForTimeStyle(EStyle timeStyle
, 
1349                                          const Locale
& locale
, 
1350                                          UResourceBundle
* dateTimePatterns
, 
1351                                          UnicodeString
& ovrStr
, 
1352                                          UErrorCode
& status
); 
1353     UnicodeString 
getPatternForDateStyle(EStyle dateStyle
, 
1354                                          UResourceBundle
* languageDateTimePatterns
, 
1355                                          UResourceBundle
* countryDateTimePatterns
, 
1356                                          UBool
& fallingBackByCountry
, 
1357                                          UnicodeString
& ovrStr
, 
1358                                          UErrorCode
& status
); 
1359     UnicodeString 
getPatternString(int32_t index
, 
1360                                    UResourceBundle
* dateTimePatterns
, 
1361                                    UnicodeString
& ovrStr
, 
1362                                    UErrorCode
& status
); 
1366      * Called by construct() and the various constructors to set up the SimpleDateFormat's 
1367      * Calendar and NumberFormat objects. 
1368      * @param locale    The locale for which we want a Calendar and a NumberFormat. 
1369      * @param status    Filled in with an error code if creating either subobject fails. 
1371     void initialize(const Locale
& locale
, UErrorCode
& status
); 
1374      * Private code-size reduction function used by subParse. 
1375      * @param text the time text being parsed. 
1376      * @param start where to start parsing. 
1377      * @param field the date field being parsed. 
1378      * @param stringArray the string array to parsed. 
1379      * @param stringArrayCount the size of the array. 
1380      * @param monthPattern pointer to leap month pattern, or NULL if none. 
1381      * @param cal a Calendar set to the date and time to be formatted 
1382      *            into a date/time string. 
1383      * @return the new start position if matching succeeded; a negative number 
1384      * indicating matching failure, otherwise. 
1386     int32_t matchString(const UnicodeString
& text
, int32_t start
, UCalendarDateFields field
, 
1387                         const UnicodeString
* stringArray
, int32_t stringArrayCount
, 
1388                         const UnicodeString
* monthPattern
, Calendar
& cal
) const; 
1391      * Private code-size reduction function used by subParse. 
1392      * @param text the time text being parsed. 
1393      * @param start where to start parsing. 
1394      * @param field the date field being parsed. 
1395      * @param stringArray the string array to parsed. 
1396      * @param stringArrayCount the size of the array. 
1397      * @param cal a Calendar set to the date and time to be formatted 
1398      *            into a date/time string. 
1399      * @return the new start position if matching succeeded; a negative number 
1400      * indicating matching failure, otherwise. 
1402     int32_t matchQuarterString(const UnicodeString
& text
, int32_t start
, UCalendarDateFields field
, 
1403                                const UnicodeString
* stringArray
, int32_t stringArrayCount
, Calendar
& cal
) const; 
1406      * Used by subParse() to match localized day period strings. 
1408     int32_t matchDayPeriodStrings(const UnicodeString
& text
, int32_t start
, 
1409                                   const UnicodeString
* stringArray
, int32_t stringArrayCount
, 
1410                                   int32_t &dayPeriod
) const; 
1413      * Private function used by subParse to match literal pattern text. 
1415      * @param pattern the pattern string 
1416      * @param patternOffset the starting offset into the pattern text. On 
1417      *        outupt will be set the offset of the first non-literal character in the pattern 
1418      * @param text the text being parsed 
1419      * @param textOffset the starting offset into the text. On output 
1420      *                   will be set to the offset of the character after the match 
1421      * @param whitespaceLenient <code>TRUE</code> if whitespace parse is lenient, <code>FALSE</code> otherwise. 
1422      * @param partialMatchLenient <code>TRUE</code> if partial match parse is lenient, <code>FALSE</code> otherwise. 
1423      * @param oldLeniency <code>TRUE</code> if old leniency control is lenient, <code>FALSE</code> otherwise. 
1425      * @return <code>TRUE</code> if the literal text could be matched, <code>FALSE</code> otherwise. 
1427     static UBool 
matchLiterals(const UnicodeString 
&pattern
, int32_t &patternOffset
, 
1428                                const UnicodeString 
&text
, int32_t &textOffset
, 
1429                                UBool whitespaceLenient
, UBool partialMatchLenient
, UBool oldLeniency
); 
1432      * Private member function that converts the parsed date strings into 
1433      * timeFields. Returns -start (for ParsePosition) if failed. 
1434      * @param text the time text to be parsed. 
1435      * @param start where to start parsing. 
1436      * @param ch the pattern character for the date field text to be parsed. 
1437      * @param count the count of a pattern character. 
1438      * @param obeyCount if true then the count is strictly obeyed. 
1439      * @param allowNegative 
1440      * @param ambiguousYear If true then the two-digit year == the default start year. 
1441      * @param saveHebrewMonth Used to hang onto month until year is known. 
1442      * @param cal a Calendar set to the date and time to be formatted 
1443      *            into a date/time string. 
1445      * @param numericLeapMonthFormatter If non-null, used to parse numeric leap months. 
1446      * @param tzTimeType the type of parsed time zone - standard, daylight or unknown (output). 
1447      *      This parameter can be NULL if caller does not need the information. 
1448      * @return the new start position if matching succeeded; a negative number 
1449      * indicating matching failure, otherwise. 
1451     int32_t subParse(const UnicodeString
& text
, int32_t& start
, char16_t ch
, int32_t count
, 
1452                      UBool obeyCount
, UBool allowNegative
, UBool ambiguousYear
[], int32_t& saveHebrewMonth
, Calendar
& cal
, 
1453                      int32_t patLoc
, MessageFormat 
* numericLeapMonthFormatter
, UTimeZoneFormatTimeType 
*tzTimeType
, 
1454                      int32_t *dayPeriod
=NULL
) const; 
1456     void parseInt(const UnicodeString
& text
, 
1457                   Formattable
& number
, 
1459                   UBool allowNegative
, 
1460                   const NumberFormat 
*fmt
) const; 
1462     void parseInt(const UnicodeString
& text
, 
1463                   Formattable
& number
, 
1466                   UBool allowNegative
, 
1467                   const NumberFormat 
*fmt
) const; 
1469     int32_t checkIntSuffix(const UnicodeString
& text
, int32_t start
, 
1470                            int32_t patLoc
, UBool isNegative
) const; 
1473      * Counts number of digit code points in the specified text. 
1475      * @param text  input text 
1476      * @param start start index, inclusive 
1477      * @param end   end index, exclusive 
1478      * @return  number of digits found in the text in the specified range. 
1480     int32_t countDigits(const UnicodeString
& text
, int32_t start
, int32_t end
) const; 
1483      * Translate a pattern, mapping each character in the from string to the 
1484      * corresponding character in the to string. Return an error if the original 
1485      * pattern contains an unmapped character, or if a quote is unmatched. 
1486      * Quoted (single quotes only) material is not translated. 
1487      * @param originalPattern   the original pattern. 
1488      * @param translatedPattern Output param to receive the translited pattern. 
1489      * @param from              the characters to be translited from. 
1490      * @param to                the characters to be translited to. 
1491      * @param status            Receives a status code, which will be U_ZERO_ERROR 
1492      *                          if the operation succeeds. 
1494     static void translatePattern(const UnicodeString
& originalPattern
, 
1495                                 UnicodeString
& translatedPattern
, 
1496                                 const UnicodeString
& from
, 
1497                                 const UnicodeString
& to
, 
1498                                 UErrorCode
& status
); 
1501      * Sets the starting date of the 100-year window that dates with 2-digit years 
1502      * are considered to fall within. 
1503      * @param startDate the start date 
1504      * @param status    Receives a status code, which will be U_ZERO_ERROR 
1505      *                  if the operation succeeds. 
1507     void         parseAmbiguousDatesAsAfter(UDate startDate
, UErrorCode
& status
); 
1510      * Return the length matched by the given affix, or -1 if none. 
1511      * Runs of white space in the affix, match runs of white space in 
1513      * @param affix pattern string, taken as a literal 
1514      * @param input input text 
1515      * @param pos offset into input at which to begin matching 
1516      * @return length of input that matches, or -1 if match failure 
1518     int32_t compareSimpleAffix(const UnicodeString
& affix
, 
1519                    const UnicodeString
& input
, 
1523      * Skip over a run of zero or more Pattern_White_Space characters at 
1526     int32_t skipPatternWhiteSpace(const UnicodeString
& text
, int32_t pos
) const; 
1529      * Skip over a run of zero or more isUWhiteSpace() characters at pos 
1532     int32_t skipUWhiteSpace(const UnicodeString
& text
, int32_t pos
) const; 
1535      * Initialize LocalizedNumberFormatter instances used for speedup. 
1537     void initFastNumberFormatters(UErrorCode
& status
); 
1540      * Delete the LocalizedNumberFormatter instances used for speedup. 
1542     void freeFastNumberFormatters(); 
1545      * Initialize NumberFormat instances used for numbering system overrides. 
1547     void initNumberFormatters(const Locale 
&locale
,UErrorCode 
&status
); 
1550      * Parse the given override string and set up structures for number formats 
1552     void processOverrideString(const Locale 
&locale
, const UnicodeString 
&str
, int8_t type
, UErrorCode 
&status
); 
1555      * Used to map pattern characters to Calendar field identifiers. 
1557     static const UCalendarDateFields fgPatternIndexToCalendarField
[]; 
1560      * Map index into pattern character string to DateFormat field number 
1562     static const UDateFormatField fgPatternIndexToDateFormatField
[]; 
1565      * Lazy TimeZoneFormat instantiation, semantically const 
1567     TimeZoneFormat 
*tzFormat(UErrorCode 
&status
) const; 
1569     const NumberFormat
* getNumberFormatByIndex(UDateFormatField index
) const; 
1572      * Used to map Calendar field to field level. 
1573      * The larger the level, the smaller the field unit. 
1574      * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10, 
1575      * UCAL_MONTH level is 20. 
1577     static const int32_t fgCalendarFieldToLevel
[]; 
1580      * Map calendar field letter into calendar field level. 
1582     static int32_t getLevelFromChar(char16_t ch
); 
1585      * Tell if a character can be used to define a field in a format string. 
1587     static UBool 
isSyntaxChar(char16_t ch
); 
1590      * The formatting pattern for this formatter. 
1592     UnicodeString       fPattern
; 
1595      * The numbering system override for dates. 
1597     UnicodeString       fDateOverride
; 
1600      * The numbering system override for times. 
1602     UnicodeString       fTimeOverride
; 
1606      * The original locale used (for reloading symbols) 
1611      * A pointer to an object containing the strings to use in formatting (e.g., 
1612      * month and day names, AM and PM strings, time zone names, etc.) 
1614     DateFormatSymbols
*  fSymbols
;   // Owned 
1617      * The time zone formatter 
1619     TimeZoneFormat
* fTimeZoneFormat
; 
1622      * If dates have ambiguous years, we map them into the century starting 
1623      * at defaultCenturyStart, which may be any date.  If defaultCenturyStart is 
1624      * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system 
1625      * values are used.  The instance values defaultCenturyStart and 
1626      * defaultCenturyStartYear are only used if explicitly set by the user 
1627      * through the API method parseAmbiguousDatesAsAfter(). 
1629     UDate                fDefaultCenturyStart
; 
1633     UBool                fHasHanYearChar
; // pattern contains the Han year character \u5E74 
1636      * Sets fHasMinutes and fHasSeconds. 
1638     void                 parsePattern(); 
1641      * See documentation for defaultCenturyStart. 
1643     /*transient*/ int32_t   fDefaultCenturyStartYear
; 
1645     struct NSOverride 
: public UMemory 
{ 
1646         const SharedNumberFormat 
*snf
; 
1650         NSOverride() : snf(NULL
), hash(0), next(NULL
) { 
1656      * The number format in use for each date field. NULL means fall back 
1657      * to fNumberFormat in DateFormat. 
1659     const SharedNumberFormat    
**fSharedNumberFormatters
; 
1661     enum NumberFormatterKey 
{ 
1671      * Number formatters pre-allocated for fast performance on the most common integer lengths. 
1673     const number::LocalizedNumberFormatter
* fFastNumberFormatters
[SMPDTFMT_NF_COUNT
] = {}; 
1675     UBool fHaveDefaultCentury
; 
1677     BreakIterator
* fCapitalizationBrkIter
; 
1681 SimpleDateFormat::get2DigitYearStart(UErrorCode
& /*status*/) const 
1683     return fDefaultCenturyStart
; 
1686 inline BreakIterator
* 
1687 SimpleDateFormat::getCapitalizationBrkIter() const 
1689     return fCapitalizationBrkIter
; 
1694 #endif /* #if !UCONFIG_NO_FORMATTING */ 
1696 #endif /* U_SHOW_CPLUSPLUS_API */