jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: * Copyright (C) 1997-2016, International Business Machines Corporation and jpayne@69: * others. All Rights Reserved. jpayne@69: ******************************************************************************* jpayne@69: * jpayne@69: * File SMPDTFMT.H jpayne@69: * jpayne@69: * Modification History: jpayne@69: * jpayne@69: * Date Name Description jpayne@69: * 02/19/97 aliu Converted from java. jpayne@69: * 07/09/97 helena Make ParsePosition into a class. jpayne@69: * 07/21/98 stephen Added GMT_PLUS, GMT_MINUS jpayne@69: * Changed setTwoDigitStartDate to set2DigitYearStart jpayne@69: * Changed getTwoDigitStartDate to get2DigitYearStart jpayne@69: * Removed subParseLong jpayne@69: * Removed getZoneIndex (added in DateFormatSymbols) jpayne@69: * 06/14/99 stephen Removed fgTimeZoneDataSuffix jpayne@69: * 10/14/99 aliu Updated class doc to describe 2-digit year parsing jpayne@69: * {j28 4182066}. jpayne@69: ******************************************************************************* jpayne@69: */ jpayne@69: jpayne@69: #ifndef SMPDTFMT_H jpayne@69: #define SMPDTFMT_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C++ API: Format and parse dates in a language-independent manner. jpayne@69: */ jpayne@69: jpayne@69: #if !UCONFIG_NO_FORMATTING jpayne@69: jpayne@69: #include "unicode/datefmt.h" jpayne@69: #include "unicode/udisplaycontext.h" jpayne@69: #include "unicode/tzfmt.h" /* for UTimeZoneFormatTimeType */ jpayne@69: #include "unicode/brkiter.h" jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: class DateFormatSymbols; jpayne@69: class DateFormat; jpayne@69: class MessageFormat; jpayne@69: class FieldPositionHandler; jpayne@69: class TimeZoneFormat; jpayne@69: class SharedNumberFormat; jpayne@69: class SimpleDateFormatMutableNFs; jpayne@69: class DateIntervalFormat; jpayne@69: jpayne@69: namespace number { jpayne@69: class LocalizedNumberFormatter; jpayne@69: } jpayne@69: jpayne@69: /** jpayne@69: * jpayne@69: * SimpleDateFormat is a concrete class for formatting and parsing dates in a jpayne@69: * language-independent manner. It allows for formatting (millis -> text), jpayne@69: * parsing (text -> millis), and normalization. Formats/Parses a date or time, jpayne@69: * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970. jpayne@69: *
jpayne@69: * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(), jpayne@69: * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than jpayne@69: * explicitly constructing an instance of SimpleDateFormat. This way, the client jpayne@69: * is guaranteed to get an appropriate formatting pattern for whatever locale the jpayne@69: * program is running in. However, if the client needs something more unusual than jpayne@69: * the default patterns in the locales, he can construct a SimpleDateFormat directly jpayne@69: * and give it an appropriate pattern (or use one of the factory methods on DateFormat jpayne@69: * and modify the pattern after the fact with toPattern() and applyPattern(). jpayne@69: * jpayne@69: *
Date and Time Patterns:
jpayne@69: * jpayne@69: *Date and time formats are specified by date and time pattern strings.
jpayne@69: * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved
jpayne@69: * as pattern letters representing calendar fields. SimpleDateFormat
supports
jpayne@69: * the date and time formatting algorithm and pattern letters defined by
jpayne@69: * UTS#35
jpayne@69: * Unicode Locale Data Markup Language (LDML) and further documented for ICU in the
jpayne@69: * ICU
jpayne@69: * User Guide. The following pattern letters are currently available (note that the actual
jpayne@69: * values depend on CLDR and may change from the examples shown here):
Field | jpayne@69: *Sym. | jpayne@69: *No. | jpayne@69: *Example | jpayne@69: *Description | jpayne@69: *||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
era | jpayne@69: *G | jpayne@69: *1..3 | jpayne@69: *AD | jpayne@69: *Era - Replaced with the Era string for the current date. One to three letters for the jpayne@69: * abbreviated form, four letters for the long (wide) form, five for the narrow form. | jpayne@69: *||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Anno Domini | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *A | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
year | jpayne@69: *y | jpayne@69: *1..n | jpayne@69: *1996 | jpayne@69: *Year. Normally the length specifies the padding, but for two letters it also specifies the maximum
jpayne@69: * length. Example:
jpayne@69: *
jpayne@69: *
|
jpayne@69: * ||||||||||||||||||||||||||||||||||||
Y | jpayne@69: *1..n | jpayne@69: *1997 | jpayne@69: *Year (in "Week of Year" based calendars). Normally the length specifies the padding, jpayne@69: * but for two letters it also specifies the maximum length. This year designation is used in ISO jpayne@69: * year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems jpayne@69: * where week date processing is desired. May not always be the same value as calendar year. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
u | jpayne@69: *1..n | jpayne@69: *4601 | jpayne@69: *Extended year. This is a single number designating the year of this calendar system, encompassing jpayne@69: * all supra-year fields. For example, for the Julian calendar system, year numbers are positive, with an jpayne@69: * era of BCE or CE. An extended year value for the Julian calendar system assigns positive values to CE jpayne@69: * years and negative values to BCE years, with 1 BCE being year 0. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
U | jpayne@69: *1..3 | jpayne@69: *甲子 | jpayne@69: *Cyclic year name. Calendars such as the Chinese lunar calendar (and related calendars) jpayne@69: * and the Hindu calendars use 60-year cycles of year names. Use one through three letters for the abbreviated jpayne@69: * name, four for the full (wide) name, or five for the narrow name (currently the data only provides abbreviated names, jpayne@69: * which will be used for all requested name widths). If the calendar does not provide cyclic year name data, jpayne@69: * or if the year value to be formatted is out of the range of years for which cyclic name data is provided, jpayne@69: * then numeric formatting is used (behaves like 'y'). | jpayne@69: *|||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *(currently also 甲子) | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *(currently also 甲子) | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
quarter | jpayne@69: *Q | jpayne@69: *1..2 | jpayne@69: *02 | jpayne@69: *Quarter - Use one or two for the numerical quarter, three for the abbreviation, or four for the jpayne@69: * full (wide) name (five for the narrow name is not yet supported). | jpayne@69: *||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Q2 | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *2nd quarter | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
q | jpayne@69: *1..2 | jpayne@69: *02 | jpayne@69: *Stand-Alone Quarter - Use one or two for the numerical quarter, three for the abbreviation, jpayne@69: * or four for the full name (five for the narrow name is not yet supported). | jpayne@69: *|||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Q2 | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *2nd quarter | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
month | jpayne@69: *M | jpayne@69: *1..2 | jpayne@69: *09 | jpayne@69: *Month - Use one or two for the numerical month, three for the abbreviation, four for jpayne@69: * the full (wide) name, or five for the narrow name. With two ("MM"), the month number is zero-padded jpayne@69: * if necessary (e.g. "08") | jpayne@69: *||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Sep | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *September | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *S | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
L | jpayne@69: *1..2 | jpayne@69: *09 | jpayne@69: *Stand-Alone Month - Use one or two for the numerical month, three for the abbreviation, jpayne@69: * four for the full (wide) name, or 5 for the narrow name. With two ("LL"), the month number is zero-padded if jpayne@69: * necessary (e.g. "08") | jpayne@69: *|||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Sep | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *September | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *S | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
week | jpayne@69: *w | jpayne@69: *1..2 | jpayne@69: *27 | jpayne@69: *Week of Year. Use "w" to show the minimum number of digits, or "ww" to always show two digits jpayne@69: * (zero-padding if necessary, e.g. "08"). | jpayne@69: *||||||||||||||||||||||||||||||||||||
W | jpayne@69: *1 | jpayne@69: *3 | jpayne@69: *Week of Month | jpayne@69: *|||||||||||||||||||||||||||||||||||||
day | jpayne@69: *d | jpayne@69: *1..2 | jpayne@69: *1 | jpayne@69: *Date - Day of the month. Use "d" to show the minimum number of digits, or "dd" to always show jpayne@69: * two digits (zero-padding if necessary, e.g. "08"). | jpayne@69: *||||||||||||||||||||||||||||||||||||
D | jpayne@69: *1..3 | jpayne@69: *345 | jpayne@69: *Day of year | jpayne@69: *|||||||||||||||||||||||||||||||||||||
F | jpayne@69: *1 | jpayne@69: *2 | jpayne@69: *Day of Week in Month. The example is for the 2nd Wed in July | jpayne@69: *|||||||||||||||||||||||||||||||||||||
g | jpayne@69: *1..n | jpayne@69: *2451334 | jpayne@69: *Modified Julian day. This is different from the conventional Julian day number in two regards. jpayne@69: * First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; jpayne@69: * that is, it depends on the local time zone. It can be thought of as a single number that encompasses jpayne@69: * all the date-related fields. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
week jpayne@69: * day |
jpayne@69: * E | jpayne@69: *1..3 | jpayne@69: *Tue | jpayne@69: *Day of week - Use one through three letters for the short day, four for the full (wide) name, jpayne@69: * five for the narrow name, or six for the short name. | jpayne@69: *||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Tuesday | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *T | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
6 | jpayne@69: *Tu | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
e | jpayne@69: *1..2 | jpayne@69: *2 | jpayne@69: *Local day of week. Same as E except adds a numeric value that will depend on the local jpayne@69: * starting day of the week, using one or two letters. For this example, Monday is the first day of the week. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Tue | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Tuesday | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *T | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
6 | jpayne@69: *Tu | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
c | jpayne@69: *1 | jpayne@69: *2 | jpayne@69: *Stand-Alone local day of week - Use one letter for the local numeric value (same jpayne@69: * as 'e'), three for the short day, four for the full (wide) name, five for the narrow name, or six for jpayne@69: * the short name. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Tue | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Tuesday | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *T | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
6 | jpayne@69: *Tu | jpayne@69: *|||||||||||||||||||||||||||||||||||||||
period | jpayne@69: *a | jpayne@69: *1 | jpayne@69: *AM | jpayne@69: *AM or PM | jpayne@69: *||||||||||||||||||||||||||||||||||||
hour | jpayne@69: *h | jpayne@69: *1..2 | jpayne@69: *11 | jpayne@69: *Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern jpayne@69: * generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match jpayne@69: * a 24-hour-cycle format (H or k). Use hh for zero padding. | jpayne@69: *||||||||||||||||||||||||||||||||||||
H | jpayne@69: *1..2 | jpayne@69: *13 | jpayne@69: *Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern jpayne@69: * generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a jpayne@69: * 12-hour-cycle format (h or K). Use HH for zero padding. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
K | jpayne@69: *1..2 | jpayne@69: *0 | jpayne@69: *Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
k | jpayne@69: *1..2 | jpayne@69: *24 | jpayne@69: *Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
minute | jpayne@69: *m | jpayne@69: *1..2 | jpayne@69: *59 | jpayne@69: *Minute. Use "m" to show the minimum number of digits, or "mm" to always show two digits jpayne@69: * (zero-padding if necessary, e.g. "08"). | jpayne@69: *||||||||||||||||||||||||||||||||||||
second | jpayne@69: *s | jpayne@69: *1..2 | jpayne@69: *12 | jpayne@69: *Second. Use "s" to show the minimum number of digits, or "ss" to always show two digits jpayne@69: * (zero-padding if necessary, e.g. "08"). | jpayne@69: *||||||||||||||||||||||||||||||||||||
S | jpayne@69: *1..n | jpayne@69: *3450 | jpayne@69: *Fractional Second - truncates (like other time fields) to the count of letters when formatting. jpayne@69: * Appends zeros if more than 3 letters specified. Truncates at three significant digits when parsing. jpayne@69: * (example shows display using pattern SSSS for seconds value 12.34567) | jpayne@69: *|||||||||||||||||||||||||||||||||||||
A | jpayne@69: *1..n | jpayne@69: *69540000 | jpayne@69: *Milliseconds in day. This field behaves exactly like a composite of all time-related fields, jpayne@69: * not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition jpayne@69: * days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This jpayne@69: * reflects the fact that is must be combined with the offset field to obtain a unique local time value. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
zone | jpayne@69: *z | jpayne@69: *1..3 | jpayne@69: *PDT | jpayne@69: *The short specific non-location format. jpayne@69: * Where that is unavailable, falls back to the short localized GMT format ("O"). | jpayne@69: *||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Pacific Daylight Time | jpayne@69: *The long specific non-location format. jpayne@69: * Where that is unavailable, falls back to the long localized GMT format ("OOOO"). | jpayne@69: *||||||||||||||||||||||||||||||||||||||
Z | jpayne@69: *1..3 | jpayne@69: *-0800 | jpayne@69: *The ISO8601 basic format with hours, minutes and optional seconds fields. jpayne@69: * The format is equivalent to RFC 822 zone format (when optional seconds field is absent). jpayne@69: * This is equivalent to the "xxxx" specifier. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *GMT-8:00 | jpayne@69: *The long localized GMT format. jpayne@69: * This is equivalent to the "OOOO" specifier. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *-08:00 jpayne@69: * -07:52:58 |
jpayne@69: * The ISO8601 extended format with hours, minutes and optional seconds fields. jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. jpayne@69: * This is equivalent to the "XXXXX" specifier. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
O | jpayne@69: *1 | jpayne@69: *GMT-8 | jpayne@69: *The short localized GMT format. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *GMT-08:00 | jpayne@69: *The long localized GMT format. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
v | jpayne@69: *1 | jpayne@69: *PT | jpayne@69: *The short generic non-location format. jpayne@69: * Where that is unavailable, falls back to the generic location format ("VVVV"), jpayne@69: * then the short localized GMT format as the final fallback. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Pacific Time | jpayne@69: *The long generic non-location format. jpayne@69: * Where that is unavailable, falls back to generic location format ("VVVV"). jpayne@69: * | ||||||||||||||||||||||||||||||||||||||
V | jpayne@69: *1 | jpayne@69: *uslax | jpayne@69: *The short time zone ID.
jpayne@69: * Where that is unavailable, the special short time zone ID unk (Unknown Zone) is used. jpayne@69: * Note: This specifier was originally used for a variant of the short specific non-location format, jpayne@69: * but it was deprecated in the later version of the LDML specification. In CLDR 23/ICU 51, the definition of jpayne@69: * the specifier was changed to designate a short time zone ID. |
jpayne@69: * |||||||||||||||||||||||||||||||||||||
2 | jpayne@69: *America/Los_Angeles | jpayne@69: *The long time zone ID. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *Los Angeles | jpayne@69: *The exemplar city (location) for the time zone. jpayne@69: * Where that is unavailable, the localized exemplar city name for the special zone Etc/Unknown is used jpayne@69: * as the fallback (for example, "Unknown City"). | jpayne@69: *||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *Los Angeles Time | jpayne@69: *The generic location format.
jpayne@69: * Where that is unavailable, falls back to the long localized GMT format ("OOOO";
jpayne@69: * Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.) jpayne@69: * This is especially useful when presenting possible timezone choices for user selection, jpayne@69: * since the naming is more uniform than the "v" format. |
jpayne@69: * ||||||||||||||||||||||||||||||||||||||
X | jpayne@69: *1 | jpayne@69: *-08 jpayne@69: * +0530 jpayne@69: * Z |
jpayne@69: * The ISO8601 basic format with hours field and optional minutes field. jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
2 | jpayne@69: *-0800 jpayne@69: * Z |
jpayne@69: * The ISO8601 basic format with hours and minutes fields. jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *-08:00 jpayne@69: * Z |
jpayne@69: * The ISO8601 extended format with hours and minutes fields. jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *-0800 jpayne@69: * -075258 jpayne@69: * Z |
jpayne@69: * The ISO8601 basic format with hours, minutes and optional seconds fields. jpayne@69: * (Note: The seconds field is not supported by the ISO8601 specification.) jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *-08:00 jpayne@69: * -07:52:58 jpayne@69: * Z |
jpayne@69: * The ISO8601 extended format with hours, minutes and optional seconds fields. jpayne@69: * (Note: The seconds field is not supported by the ISO8601 specification.) jpayne@69: * The ISO8601 UTC indicator "Z" is used when local time offset is 0. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
x | jpayne@69: *1 | jpayne@69: *-08 jpayne@69: * +0530 |
jpayne@69: * The ISO8601 basic format with hours field and optional minutes field. | jpayne@69: *|||||||||||||||||||||||||||||||||||||
2 | jpayne@69: *-0800 | jpayne@69: *The ISO8601 basic format with hours and minutes fields. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
3 | jpayne@69: *-08:00 | jpayne@69: *The ISO8601 extended format with hours and minutes fields. | jpayne@69: *||||||||||||||||||||||||||||||||||||||
4 | jpayne@69: *-0800 jpayne@69: * -075258 |
jpayne@69: * The ISO8601 basic format with hours, minutes and optional seconds fields. jpayne@69: * (Note: The seconds field is not supported by the ISO8601 specification.) | jpayne@69: *||||||||||||||||||||||||||||||||||||||
5 | jpayne@69: *-08:00 jpayne@69: * -07:52:58 |
jpayne@69: * The ISO8601 extended format with hours, minutes and optional seconds fields. jpayne@69: * (Note: The seconds field is not supported by the ISO8601 specification.) | jpayne@69: *
jpayne@69: * Any characters in the pattern that are not in the ranges of ['a'..'z'] and jpayne@69: * ['A'..'Z'] will be treated as quoted text. For instance, characters jpayne@69: * like ':', '.', ' ', '#' and '@' will appear in the resulting time text jpayne@69: * even they are not embraced within single quotes. jpayne@69: *
jpayne@69: * A pattern containing any invalid pattern letter will result in a failing jpayne@69: * UErrorCode result during formatting or parsing. jpayne@69: *
jpayne@69: * Examples using the US locale: jpayne@69: *
jpayne@69: * \code jpayne@69: * Format Pattern Result jpayne@69: * -------------- ------- jpayne@69: * "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->> 1996.07.10 AD at 15:08:56 Pacific Time jpayne@69: * "EEE, MMM d, ''yy" ->> Wed, July 10, '96 jpayne@69: * "h:mm a" ->> 12:08 PM jpayne@69: * "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time jpayne@69: * "K:mm a, vvv" ->> 0:00 PM, PT jpayne@69: * "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM jpayne@69: * \endcode jpayne@69: *jpayne@69: * Code Sample: jpayne@69: *
jpayne@69: * \code jpayne@69: * UErrorCode success = U_ZERO_ERROR; jpayne@69: * SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST"); jpayne@69: * pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000); jpayne@69: * pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000); jpayne@69: * jpayne@69: * // Format the current time. jpayne@69: * SimpleDateFormat* formatter jpayne@69: * = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success ); jpayne@69: * GregorianCalendar cal(success); jpayne@69: * UDate currentTime_1 = cal.getTime(success); jpayne@69: * FieldPosition fp(FieldPosition::DONT_CARE); jpayne@69: * UnicodeString dateString; jpayne@69: * formatter->format( currentTime_1, dateString, fp ); jpayne@69: * cout << "result: " << dateString << endl; jpayne@69: * jpayne@69: * // Parse the previous string back into a Date. jpayne@69: * ParsePosition pp(0); jpayne@69: * UDate currentTime_2 = formatter->parse(dateString, pp ); jpayne@69: * \endcode jpayne@69: *jpayne@69: * In the above example, the time value "currentTime_2" obtained from parsing jpayne@69: * will be equal to currentTime_1. However, they may not be equal if the am/pm jpayne@69: * marker 'a' is left out from the format pattern while the "hour in am/pm" jpayne@69: * pattern symbol is used. This information loss can happen when formatting the jpayne@69: * time in PM. jpayne@69: * jpayne@69: *
jpayne@69: * When parsing a date string using the abbreviated year pattern ("y" or "yy"),
jpayne@69: * SimpleDateFormat must interpret the abbreviated year
jpayne@69: * relative to some century. It does this by adjusting dates to be
jpayne@69: * within 80 years before and 20 years after the time the SimpleDateFormat
jpayne@69: * instance is created. For example, using a pattern of "MM/dd/yy" and a
jpayne@69: * SimpleDateFormat instance created on Jan 1, 1997, the string
jpayne@69: * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64"
jpayne@69: * would be interpreted as May 4, 1964.
jpayne@69: * During parsing, only strings consisting of exactly two digits, as defined by
jpayne@69: * Unicode::isDigit()
, will be parsed into the default century.
jpayne@69: * Any other numeric string, such as a one digit string, a three or more digit
jpayne@69: * string, or a two digit string that isn't all digits (for example, "-1"), is
jpayne@69: * interpreted literally. So "01/02/3" or "01/02/003" are parsed (for the
jpayne@69: * Gregorian calendar), using the same pattern, as Jan 2, 3 AD. Likewise (but
jpayne@69: * only in lenient parse mode, the default) "01/02/-3" is parsed as Jan 2, 4 BC.
jpayne@69: *
jpayne@69: *
jpayne@69: * If the year pattern has more than two 'y' characters, the year is jpayne@69: * interpreted literally, regardless of the number of digits. So using the jpayne@69: * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D. jpayne@69: * jpayne@69: *
jpayne@69: * When numeric fields abut one another directly, with no intervening delimiter jpayne@69: * characters, they constitute a run of abutting numeric fields. Such runs are jpayne@69: * parsed specially. For example, the format "HHmmss" parses the input text jpayne@69: * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to jpayne@69: * parse "1234". In other words, the leftmost field of the run is flexible, jpayne@69: * while the others keep a fixed width. If the parse fails anywhere in the run, jpayne@69: * then the leftmost field is shortened by one character, and the entire run is jpayne@69: * parsed again. This is repeated until either the parse succeeds or the jpayne@69: * leftmost field is one character in length. If the parse still fails at that jpayne@69: * point, the parse of the run fails. jpayne@69: * jpayne@69: *
jpayne@69: * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or jpayne@69: * GMT-hours:minutes. jpayne@69: *
jpayne@69: * The calendar defines what is the first day of the week, the first week of the jpayne@69: * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone. jpayne@69: * There is one common number format to handle all the numbers; the digit count jpayne@69: * is handled programmatically according to the pattern. jpayne@69: * jpayne@69: *
User subclasses are not supported. While clients may write jpayne@69: * subclasses, such code will not necessarily work and will not be jpayne@69: * guaranteed to work stably from release to release. jpayne@69: */ jpayne@69: class U_I18N_API SimpleDateFormat: public DateFormat { jpayne@69: public: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the default pattern for the default jpayne@69: * locale. jpayne@69: *
jpayne@69: * [Note:] Not all locales support SimpleDateFormat; for full generality, jpayne@69: * use the factory methods in the DateFormat class. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern and the default locale. jpayne@69: * The locale is used to obtain the symbols used in formatting (e.g., the jpayne@69: * names of the months), but not to provide the pattern. jpayne@69: *
jpayne@69: * [Note:] Not all locales support SimpleDateFormat; for full generality, jpayne@69: * use the factory methods in the DateFormat class. jpayne@69: * @param pattern the pattern for the format. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern, numbering system override, and the default locale. jpayne@69: * The locale is used to obtain the symbols used in formatting (e.g., the jpayne@69: * names of the months), but not to provide the pattern. jpayne@69: *
jpayne@69: * A numbering system override is a string containing either the name of a known numbering system, jpayne@69: * or a set of field and numbering system pairs that specify which fields are to be formattied with jpayne@69: * the alternate numbering system. For example, to specify that all numeric fields in the specified jpayne@69: * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override jpayne@69: * as "thai". To specify that just the year portion of the date be formatted using Hebrew numbering, jpayne@69: * use the override string "y=hebrew". Numbering system overrides can be combined using a semi-colon jpayne@69: * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc. jpayne@69: * jpayne@69: *
jpayne@69: * [Note:] Not all locales support SimpleDateFormat; for full generality, jpayne@69: * use the factory methods in the DateFormat class. jpayne@69: * @param pattern the pattern for the format. jpayne@69: * @param override the override string. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @stable ICU 4.2 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: const UnicodeString& override, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern and locale. jpayne@69: * The locale is used to obtain the symbols used in formatting (e.g., the jpayne@69: * names of the months), but not to provide the pattern. jpayne@69: *
jpayne@69: * [Note:] Not all locales support SimpleDateFormat; for full generality, jpayne@69: * use the factory methods in the DateFormat class. jpayne@69: * @param pattern the pattern for the format. jpayne@69: * @param locale the given locale. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: const Locale& locale, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern, numbering system override, and locale. jpayne@69: * The locale is used to obtain the symbols used in formatting (e.g., the jpayne@69: * names of the months), but not to provide the pattern. jpayne@69: *
jpayne@69: * A numbering system override is a string containing either the name of a known numbering system, jpayne@69: * or a set of field and numbering system pairs that specify which fields are to be formattied with jpayne@69: * the alternate numbering system. For example, to specify that all numeric fields in the specified jpayne@69: * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override jpayne@69: * as "thai". To specify that just the year portion of the date be formatted using Hebrew numbering, jpayne@69: * use the override string "y=hebrew". Numbering system overrides can be combined using a semi-colon jpayne@69: * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc. jpayne@69: *
jpayne@69: * [Note:] Not all locales support SimpleDateFormat; for full generality, jpayne@69: * use the factory methods in the DateFormat class. jpayne@69: * @param pattern the pattern for the format. jpayne@69: * @param override the numbering system override. jpayne@69: * @param locale the given locale. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @stable ICU 4.2 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: const UnicodeString& override, jpayne@69: const Locale& locale, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern and locale-specific jpayne@69: * symbol data. The formatter takes ownership of the DateFormatSymbols object; jpayne@69: * the caller is no longer responsible for deleting it. jpayne@69: * @param pattern the given pattern for the format. jpayne@69: * @param formatDataToAdopt the symbols to be adopted. jpayne@69: * @param status Output param set to success/faulure code. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: DateFormatSymbols* formatDataToAdopt, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat using the given pattern and locale-specific jpayne@69: * symbol data. The DateFormatSymbols object is NOT adopted; the caller jpayne@69: * remains responsible for deleting it. jpayne@69: * @param pattern the given pattern for the format. jpayne@69: * @param formatData the formatting symbols to be use. jpayne@69: * @param status Output param set to success/faulure code. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(const UnicodeString& pattern, jpayne@69: const DateFormatSymbols& formatData, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Copy constructor. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat(const SimpleDateFormat&); jpayne@69: jpayne@69: /** jpayne@69: * Assignment operator. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: SimpleDateFormat& operator=(const SimpleDateFormat&); jpayne@69: jpayne@69: /** jpayne@69: * Destructor. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual ~SimpleDateFormat(); jpayne@69: jpayne@69: /** jpayne@69: * Clone this Format object polymorphically. The caller owns the result and jpayne@69: * should delete it when done. jpayne@69: * @return A copy of the object. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual SimpleDateFormat* clone() const; jpayne@69: jpayne@69: /** jpayne@69: * Return true if the given Format objects are semantically equal. Objects jpayne@69: * of different subclasses are considered unequal. jpayne@69: * @param other the object to be compared with. jpayne@69: * @return true if the given Format objects are semantically equal. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual UBool operator==(const Format& other) const; jpayne@69: jpayne@69: jpayne@69: using DateFormat::format; jpayne@69: jpayne@69: /** jpayne@69: * Format a date or time, which is the standard millis since 24:00 GMT, Jan jpayne@69: * 1, 1970. Overrides DateFormat pure virtual method. jpayne@69: *
jpayne@69: * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->> jpayne@69: * 1996.07.10 AD at 15:08:56 PDT jpayne@69: * jpayne@69: * @param cal Calendar set to the date and time to be formatted jpayne@69: * into a date/time string. jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param pos The formatting position. On input: an alignment field, jpayne@69: * if desired. On output: the offsets of the alignment field. jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: virtual UnicodeString& format( Calendar& cal, jpayne@69: UnicodeString& appendTo, jpayne@69: FieldPosition& pos) const; jpayne@69: jpayne@69: /** jpayne@69: * Format a date or time, which is the standard millis since 24:00 GMT, Jan jpayne@69: * 1, 1970. Overrides DateFormat pure virtual method. jpayne@69: *
jpayne@69: * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->> jpayne@69: * 1996.07.10 AD at 15:08:56 PDT jpayne@69: * jpayne@69: * @param cal Calendar set to the date and time to be formatted jpayne@69: * into a date/time string. jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param posIter On return, can be used to iterate over positions jpayne@69: * of fields generated by this format call. Field values jpayne@69: * are defined in UDateFormatField. jpayne@69: * @param status Input/output param set to success/failure code. jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @stable ICU 4.4 jpayne@69: */ jpayne@69: virtual UnicodeString& format( Calendar& cal, jpayne@69: UnicodeString& appendTo, jpayne@69: FieldPositionIterator* posIter, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: using DateFormat::parse; jpayne@69: jpayne@69: /** jpayne@69: * Parse a date/time string beginning at the given parse position. For jpayne@69: * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date jpayne@69: * that is equivalent to Date(837039928046). jpayne@69: *
jpayne@69: * By default, parsing is lenient: If the input is not in the form used by jpayne@69: * this object's format method but can still be parsed as a date, then the jpayne@69: * parse succeeds. Clients may insist on strict adherence to the format by jpayne@69: * calling setLenient(false). jpayne@69: * @see DateFormat::setLenient(boolean) jpayne@69: * jpayne@69: * @param text The date/time string to be parsed jpayne@69: * @param cal A Calendar set on input to the date and time to be used for jpayne@69: * missing values in the date/time string being parsed, and set jpayne@69: * on output to the parsed date/time. When the calendar type is jpayne@69: * different from the internal calendar held by this SimpleDateFormat jpayne@69: * instance, the internal calendar will be cloned to a work jpayne@69: * calendar set to the same milliseconds and time zone as the jpayne@69: * cal parameter, field values will be parsed based on the work jpayne@69: * calendar, then the result (milliseconds and time zone) will jpayne@69: * be set in this calendar. jpayne@69: * @param pos On input, the position at which to start parsing; on jpayne@69: * output, the position at which parsing terminated, or the jpayne@69: * start position if the parse failed. jpayne@69: * @stable ICU 2.1 jpayne@69: */ jpayne@69: virtual void parse( const UnicodeString& text, jpayne@69: Calendar& cal, jpayne@69: ParsePosition& pos) const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set the start UDate used to interpret two-digit year strings. jpayne@69: * When dates are parsed having 2-digit year strings, they are placed within jpayne@69: * a assumed range of 100 years starting on the two digit start date. For jpayne@69: * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or jpayne@69: * some other year. SimpleDateFormat chooses a year so that the resultant jpayne@69: * date is on or after the two digit start date and within 100 years of the jpayne@69: * two digit start date. jpayne@69: *
jpayne@69: * By default, the two digit start date is set to 80 years before the current jpayne@69: * time at which a SimpleDateFormat object is created. jpayne@69: * @param d start UDate used to interpret two-digit year strings. jpayne@69: * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with jpayne@69: * an error value if there was a parse error. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void set2DigitYearStart(UDate d, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Get the start UDate used to interpret two-digit year strings. jpayne@69: * When dates are parsed having 2-digit year strings, they are placed within jpayne@69: * a assumed range of 100 years starting on the two digit start date. For jpayne@69: * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or jpayne@69: * some other year. SimpleDateFormat chooses a year so that the resultant jpayne@69: * date is on or after the two digit start date and within 100 years of the jpayne@69: * two digit start date. jpayne@69: *
jpayne@69: * By default, the two digit start date is set to 80 years before the current jpayne@69: * time at which a SimpleDateFormat object is created. jpayne@69: * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with jpayne@69: * an error value if there was a parse error. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: UDate get2DigitYearStart(UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Return a pattern string describing this date format. jpayne@69: * @param result Output param to receive the pattern. jpayne@69: * @return A reference to 'result'. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual UnicodeString& toPattern(UnicodeString& result) const; jpayne@69: jpayne@69: /** jpayne@69: * Return a localized pattern string describing this date format. jpayne@69: * In most cases, this will return the same thing as toPattern(), jpayne@69: * but a locale can specify characters to use in pattern descriptions jpayne@69: * in place of the ones described in this class's class documentation. jpayne@69: * (Presumably, letters that would be more mnemonic in that locale's jpayne@69: * language.) This function would produce a pattern using those jpayne@69: * letters. jpayne@69: *
jpayne@69: * Note: This implementation depends on DateFormatSymbols::getLocalPatternChars() jpayne@69: * to get localized format pattern characters. ICU does not include jpayne@69: * localized pattern character data, therefore, unless user sets localized jpayne@69: * pattern characters manually, this method returns the same result as jpayne@69: * toPattern(). jpayne@69: * jpayne@69: * @param result Receives the localized pattern. jpayne@69: * @param status Output param set to success/failure code on jpayne@69: * exit. If the pattern is invalid, this will be jpayne@69: * set to a failure result. jpayne@69: * @return A reference to 'result'. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual UnicodeString& toLocalizedPattern(UnicodeString& result, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Apply the given unlocalized pattern string to this date format. jpayne@69: * (i.e., after this call, this formatter will format dates according to jpayne@69: * the new pattern) jpayne@69: * jpayne@69: * @param pattern The pattern to be applied. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void applyPattern(const UnicodeString& pattern); jpayne@69: jpayne@69: /** jpayne@69: * Apply the given localized pattern string to this date format. jpayne@69: * (see toLocalizedPattern() for more information on localized patterns.) jpayne@69: * jpayne@69: * @param pattern The localized pattern to be applied. jpayne@69: * @param status Output param set to success/failure code on jpayne@69: * exit. If the pattern is invalid, this will be jpayne@69: * set to a failure result. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void applyLocalizedPattern(const UnicodeString& pattern, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Gets the date/time formatting symbols (this is an object carrying jpayne@69: * the various strings and other symbols used in formatting: e.g., month jpayne@69: * names and abbreviations, time zone names, AM/PM strings, etc.) jpayne@69: * @return a copy of the date-time formatting data associated jpayne@69: * with this date-time formatter. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual const DateFormatSymbols* getDateFormatSymbols(void) const; jpayne@69: jpayne@69: /** jpayne@69: * Set the date/time formatting symbols. The caller no longer owns the jpayne@69: * DateFormatSymbols object and should not delete it after making this call. jpayne@69: * @param newFormatSymbols the given date-time formatting symbols to copy. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void adoptDateFormatSymbols(DateFormatSymbols* newFormatSymbols); jpayne@69: jpayne@69: /** jpayne@69: * Set the date/time formatting data. jpayne@69: * @param newFormatSymbols the given date-time formatting symbols to copy. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols); jpayne@69: jpayne@69: /** jpayne@69: * Return the class ID for this class. This is useful only for comparing to jpayne@69: * a return value from getDynamicClassID(). For example: jpayne@69: *
jpayne@69: * . Base* polymorphic_pointer = createPolymorphicObject(); jpayne@69: * . if (polymorphic_pointer->getDynamicClassID() == jpayne@69: * . erived::getStaticClassID()) ... jpayne@69: *jpayne@69: * @return The class ID for all objects of this class. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: static UClassID U_EXPORT2 getStaticClassID(void); jpayne@69: jpayne@69: /** jpayne@69: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This jpayne@69: * method is to implement a simple version of RTTI, since not all C++ jpayne@69: * compilers support genuine RTTI. Polymorphic operator==() and clone() jpayne@69: * methods call this method. jpayne@69: * jpayne@69: * @return The class ID for this object. All objects of a jpayne@69: * given class have the same class ID. Objects of jpayne@69: * other classes have different class IDs. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual UClassID getDynamicClassID(void) const; jpayne@69: jpayne@69: /** jpayne@69: * Set the calendar to be used by this date format. Initially, the default jpayne@69: * calendar for the specified or default locale is used. The caller should jpayne@69: * not delete the Calendar object after it is adopted by this call. jpayne@69: * Adopting a new calendar will change to the default symbols. jpayne@69: * jpayne@69: * @param calendarToAdopt Calendar object to be adopted. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: virtual void adoptCalendar(Calendar* calendarToAdopt); jpayne@69: jpayne@69: /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since they are virtual */ jpayne@69: /** jpayne@69: * Sets the TimeZoneFormat to be used by this date/time formatter. jpayne@69: * The caller should not delete the TimeZoneFormat object after jpayne@69: * it is adopted by this call. jpayne@69: * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted. jpayne@69: * @internal ICU 49 technology preview jpayne@69: */ jpayne@69: virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt); jpayne@69: jpayne@69: /** jpayne@69: * Sets the TimeZoneFormat to be used by this date/time formatter. jpayne@69: * @param newTimeZoneFormat The TimeZoneFormat object to copy. jpayne@69: * @internal ICU 49 technology preview jpayne@69: */ jpayne@69: virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat); jpayne@69: jpayne@69: /** jpayne@69: * Gets the time zone format object associated with this date/time formatter. jpayne@69: * @return the time zone format associated with this date/time formatter. jpayne@69: * @internal ICU 49 technology preview jpayne@69: */ jpayne@69: virtual const TimeZoneFormat* getTimeZoneFormat(void) const; jpayne@69: jpayne@69: /** jpayne@69: * Set a particular UDisplayContext value in the formatter, such as jpayne@69: * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see jpayne@69: * DateFormat. jpayne@69: * @param value The UDisplayContext value to set. jpayne@69: * @param status Input/output status. If at entry this indicates a failure jpayne@69: * status, the function will do nothing; otherwise this will be jpayne@69: * updated with any new status from the function. jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: virtual void setContext(UDisplayContext value, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Overrides base class method and jpayne@69: * This method clears per field NumberFormat instances jpayne@69: * previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFormat*, UErrorCode)} jpayne@69: * @param formatToAdopt the NumbeferFormat used jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: void adoptNumberFormat(NumberFormat *formatToAdopt); jpayne@69: jpayne@69: /** jpayne@69: * Allow the user to set the NumberFormat for several fields jpayne@69: * It can be a single field like: "y"(year) or "M"(month) jpayne@69: * It can be several field combined together: "yM"(year and month) jpayne@69: * Note: jpayne@69: * 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy") jpayne@69: * If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field) jpayne@69: * Per field NumberFormat can also be cleared in {@see DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)} jpayne@69: * jpayne@69: * @param fields the fields to override(like y) jpayne@69: * @param formatToAdopt the NumbeferFormat used jpayne@69: * @param status Receives a status code, which will be U_ZERO_ERROR jpayne@69: * if the operation succeeds. jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: void adoptNumberFormat(const UnicodeString& fields, NumberFormat *formatToAdopt, UErrorCode &status); jpayne@69: jpayne@69: /** jpayne@69: * Get the numbering system to be used for a particular field. jpayne@69: * @param field The UDateFormatField to get jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: const NumberFormat * getNumberFormatForField(char16_t field) const; jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * This is for ICU internal use only. Please do not use. jpayne@69: * Check whether the 'field' is smaller than all the fields covered in jpayne@69: * pattern, return TRUE if it is. The sequence of calendar field, jpayne@69: * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... jpayne@69: * @param field the calendar field need to check against jpayne@69: * @return TRUE if the 'field' is smaller than all the fields jpayne@69: * covered in pattern. FALSE otherwise. jpayne@69: * @internal ICU 4.0 jpayne@69: */ jpayne@69: UBool isFieldUnitIgnored(UCalendarDateFields field) const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * This is for ICU internal use only. Please do not use. jpayne@69: * Check whether the 'field' is smaller than all the fields covered in jpayne@69: * pattern, return TRUE if it is. The sequence of calendar field, jpayne@69: * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... jpayne@69: * @param pattern the pattern to check against jpayne@69: * @param field the calendar field need to check against jpayne@69: * @return TRUE if the 'field' is smaller than all the fields jpayne@69: * covered in pattern. FALSE otherwise. jpayne@69: * @internal ICU 4.0 jpayne@69: */ jpayne@69: static UBool isFieldUnitIgnored(const UnicodeString& pattern, jpayne@69: UCalendarDateFields field); jpayne@69: jpayne@69: /** jpayne@69: * This is for ICU internal use only. Please do not use. jpayne@69: * Get the locale of this simple date formatter. jpayne@69: * It is used in DateIntervalFormat. jpayne@69: * jpayne@69: * @return locale in this simple date formatter jpayne@69: * @internal ICU 4.0 jpayne@69: */ jpayne@69: const Locale& getSmpFmtLocale(void) const; jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: jpayne@69: private: jpayne@69: friend class DateFormat; jpayne@69: friend class DateIntervalFormat; jpayne@69: jpayne@69: void initializeDefaultCentury(void); jpayne@69: jpayne@69: void initializeBooleanAttributes(void); jpayne@69: jpayne@69: SimpleDateFormat(); // default constructor not implemented jpayne@69: jpayne@69: /** jpayne@69: * Used by the DateFormat factory methods to construct a SimpleDateFormat. jpayne@69: * @param timeStyle the time style. jpayne@69: * @param dateStyle the date style. jpayne@69: * @param locale the given locale. jpayne@69: * @param status Output param set to success/failure code on jpayne@69: * exit. jpayne@69: */ jpayne@69: SimpleDateFormat(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a SimpleDateFormat for the given locale. If no resource data jpayne@69: * is available, create an object of last resort, using hard-coded strings. jpayne@69: * This is an internal method, called by DateFormat. It should never fail. jpayne@69: * @param locale the given locale. jpayne@69: * @param status Output param set to success/failure code on jpayne@69: * exit. jpayne@69: */ jpayne@69: SimpleDateFormat(const Locale& locale, UErrorCode& status); // Use default pattern jpayne@69: jpayne@69: /** jpayne@69: * Hook called by format(... FieldPosition& ...) and format(...FieldPositionIterator&...) jpayne@69: */ jpayne@69: UnicodeString& _format(Calendar& cal, UnicodeString& appendTo, FieldPositionHandler& handler, UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Called by format() to format a single field. jpayne@69: * jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param ch The format character we encountered in the pattern. jpayne@69: * @param count Number of characters in the current pattern symbol (e.g., jpayne@69: * "yyyy" in the pattern would result in a call to this function jpayne@69: * with ch equal to 'y' and count equal to 4) jpayne@69: * @param capitalizationContext Capitalization context for this date format. jpayne@69: * @param fieldNum Zero-based numbering of current field within the overall format. jpayne@69: * @param handler Records information about field positions. jpayne@69: * @param cal Calendar to use jpayne@69: * @param status Receives a status code, which will be U_ZERO_ERROR if the operation jpayne@69: * succeeds. jpayne@69: */ jpayne@69: void subFormat(UnicodeString &appendTo, jpayne@69: char16_t ch, jpayne@69: int32_t count, jpayne@69: UDisplayContext capitalizationContext, jpayne@69: int32_t fieldNum, jpayne@69: char16_t fieldToOutput, jpayne@69: FieldPositionHandler& handler, jpayne@69: Calendar& cal, jpayne@69: UErrorCode& status) const; // in case of illegal argument jpayne@69: jpayne@69: /** jpayne@69: * Used by subFormat() to format a numeric value. jpayne@69: * Appends to toAppendTo a string representation of "value" jpayne@69: * having a number of digits between "minDigits" and jpayne@69: * "maxDigits". Uses the DateFormat's NumberFormat. jpayne@69: * jpayne@69: * @param currentNumberFormat jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Formatted number is appended to existing contents. jpayne@69: * @param value Value to format. jpayne@69: * @param minDigits Minimum number of digits the result should have jpayne@69: * @param maxDigits Maximum number of digits the result should have jpayne@69: */ jpayne@69: void zeroPaddingNumber(const NumberFormat *currentNumberFormat, jpayne@69: UnicodeString &appendTo, jpayne@69: int32_t value, jpayne@69: int32_t minDigits, jpayne@69: int32_t maxDigits) const; jpayne@69: jpayne@69: /** jpayne@69: * Return true if the given format character, occuring count jpayne@69: * times, represents a numeric field. jpayne@69: */ jpayne@69: static UBool isNumeric(char16_t formatChar, int32_t count); jpayne@69: jpayne@69: /** jpayne@69: * Returns TRUE if the patternOffset is at the start of a numeric field. jpayne@69: */ jpayne@69: static UBool isAtNumericField(const UnicodeString &pattern, int32_t patternOffset); jpayne@69: jpayne@69: /** jpayne@69: * Returns TRUE if the patternOffset is right after a non-numeric field. jpayne@69: */ jpayne@69: static UBool isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset); jpayne@69: jpayne@69: /** jpayne@69: * initializes fCalendar from parameters. Returns fCalendar as a convenience. jpayne@69: * @param adoptZone Zone to be adopted, or NULL for TimeZone::createDefault(). jpayne@69: * @param locale Locale of the calendar jpayne@69: * @param status Error code jpayne@69: * @return the newly constructed fCalendar jpayne@69: */ jpayne@69: Calendar *initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Called by several of the constructors to load pattern data and formatting symbols jpayne@69: * out of a resource bundle and initialize the locale based on it. jpayne@69: * @param timeStyle The time style, as passed to DateFormat::createDateInstance(). jpayne@69: * @param dateStyle The date style, as passed to DateFormat::createTimeInstance(). jpayne@69: * @param locale The locale to load the patterns from. jpayne@69: * @param status Filled in with an error code if loading the data from the jpayne@69: * resources fails. jpayne@69: */ jpayne@69: void construct(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Called by construct() and the various constructors to set up the SimpleDateFormat's jpayne@69: * Calendar and NumberFormat objects. jpayne@69: * @param locale The locale for which we want a Calendar and a NumberFormat. jpayne@69: * @param status Filled in with an error code if creating either subobject fails. jpayne@69: */ jpayne@69: void initialize(const Locale& locale, UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Private code-size reduction function used by subParse. jpayne@69: * @param text the time text being parsed. jpayne@69: * @param start where to start parsing. jpayne@69: * @param field the date field being parsed. jpayne@69: * @param stringArray the string array to parsed. jpayne@69: * @param stringArrayCount the size of the array. jpayne@69: * @param monthPattern pointer to leap month pattern, or NULL if none. jpayne@69: * @param cal a Calendar set to the date and time to be formatted jpayne@69: * into a date/time string. jpayne@69: * @return the new start position if matching succeeded; a negative number jpayne@69: * indicating matching failure, otherwise. jpayne@69: */ jpayne@69: int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field, jpayne@69: const UnicodeString* stringArray, int32_t stringArrayCount, jpayne@69: const UnicodeString* monthPattern, Calendar& cal) const; jpayne@69: jpayne@69: /** jpayne@69: * Private code-size reduction function used by subParse. jpayne@69: * @param text the time text being parsed. jpayne@69: * @param start where to start parsing. jpayne@69: * @param field the date field being parsed. jpayne@69: * @param stringArray the string array to parsed. jpayne@69: * @param stringArrayCount the size of the array. jpayne@69: * @param cal a Calendar set to the date and time to be formatted jpayne@69: * into a date/time string. jpayne@69: * @return the new start position if matching succeeded; a negative number jpayne@69: * indicating matching failure, otherwise. jpayne@69: */ jpayne@69: int32_t matchQuarterString(const UnicodeString& text, int32_t start, UCalendarDateFields field, jpayne@69: const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const; jpayne@69: jpayne@69: /** jpayne@69: * Used by subParse() to match localized day period strings. jpayne@69: */ jpayne@69: int32_t matchDayPeriodStrings(const UnicodeString& text, int32_t start, jpayne@69: const UnicodeString* stringArray, int32_t stringArrayCount, jpayne@69: int32_t &dayPeriod) const; jpayne@69: jpayne@69: /** jpayne@69: * Private function used by subParse to match literal pattern text. jpayne@69: * jpayne@69: * @param pattern the pattern string jpayne@69: * @param patternOffset the starting offset into the pattern text. On jpayne@69: * outupt will be set the offset of the first non-literal character in the pattern jpayne@69: * @param text the text being parsed jpayne@69: * @param textOffset the starting offset into the text. On output jpayne@69: * will be set to the offset of the character after the match jpayne@69: * @param whitespaceLenient
TRUE
if whitespace parse is lenient, FALSE
otherwise.
jpayne@69: * @param partialMatchLenient TRUE
if partial match parse is lenient, FALSE
otherwise.
jpayne@69: * @param oldLeniency TRUE
if old leniency control is lenient, FALSE
otherwise.
jpayne@69: *
jpayne@69: * @return TRUE
if the literal text could be matched, FALSE
otherwise.
jpayne@69: */
jpayne@69: static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOffset,
jpayne@69: const UnicodeString &text, int32_t &textOffset,
jpayne@69: UBool whitespaceLenient, UBool partialMatchLenient, UBool oldLeniency);
jpayne@69:
jpayne@69: /**
jpayne@69: * Private member function that converts the parsed date strings into
jpayne@69: * timeFields. Returns -start (for ParsePosition) if failed.
jpayne@69: * @param text the time text to be parsed.
jpayne@69: * @param start where to start parsing.
jpayne@69: * @param ch the pattern character for the date field text to be parsed.
jpayne@69: * @param count the count of a pattern character.
jpayne@69: * @param obeyCount if true then the count is strictly obeyed.
jpayne@69: * @param allowNegative
jpayne@69: * @param ambiguousYear If true then the two-digit year == the default start year.
jpayne@69: * @param saveHebrewMonth Used to hang onto month until year is known.
jpayne@69: * @param cal a Calendar set to the date and time to be formatted
jpayne@69: * into a date/time string.
jpayne@69: * @param patLoc
jpayne@69: * @param numericLeapMonthFormatter If non-null, used to parse numeric leap months.
jpayne@69: * @param tzTimeType the type of parsed time zone - standard, daylight or unknown (output).
jpayne@69: * This parameter can be NULL if caller does not need the information.
jpayne@69: * @return the new start position if matching succeeded; a negative number
jpayne@69: * indicating matching failure, otherwise.
jpayne@69: */
jpayne@69: int32_t subParse(const UnicodeString& text, int32_t& start, char16_t ch, int32_t count,
jpayne@69: UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
jpayne@69: int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType,
jpayne@69: int32_t *dayPeriod=NULL) const;
jpayne@69:
jpayne@69: void parseInt(const UnicodeString& text,
jpayne@69: Formattable& number,
jpayne@69: ParsePosition& pos,
jpayne@69: UBool allowNegative,
jpayne@69: const NumberFormat *fmt) const;
jpayne@69:
jpayne@69: void parseInt(const UnicodeString& text,
jpayne@69: Formattable& number,
jpayne@69: int32_t maxDigits,
jpayne@69: ParsePosition& pos,
jpayne@69: UBool allowNegative,
jpayne@69: const NumberFormat *fmt) const;
jpayne@69:
jpayne@69: int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
jpayne@69: int32_t patLoc, UBool isNegative) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Counts number of digit code points in the specified text.
jpayne@69: *
jpayne@69: * @param text input text
jpayne@69: * @param start start index, inclusive
jpayne@69: * @param end end index, exclusive
jpayne@69: * @return number of digits found in the text in the specified range.
jpayne@69: */
jpayne@69: int32_t countDigits(const UnicodeString& text, int32_t start, int32_t end) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Translate a pattern, mapping each character in the from string to the
jpayne@69: * corresponding character in the to string. Return an error if the original
jpayne@69: * pattern contains an unmapped character, or if a quote is unmatched.
jpayne@69: * Quoted (single quotes only) material is not translated.
jpayne@69: * @param originalPattern the original pattern.
jpayne@69: * @param translatedPattern Output param to receive the translited pattern.
jpayne@69: * @param from the characters to be translited from.
jpayne@69: * @param to the characters to be translited to.
jpayne@69: * @param status Receives a status code, which will be U_ZERO_ERROR
jpayne@69: * if the operation succeeds.
jpayne@69: */
jpayne@69: static void translatePattern(const UnicodeString& originalPattern,
jpayne@69: UnicodeString& translatedPattern,
jpayne@69: const UnicodeString& from,
jpayne@69: const UnicodeString& to,
jpayne@69: UErrorCode& status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets the starting date of the 100-year window that dates with 2-digit years
jpayne@69: * are considered to fall within.
jpayne@69: * @param startDate the start date
jpayne@69: * @param status Receives a status code, which will be U_ZERO_ERROR
jpayne@69: * if the operation succeeds.
jpayne@69: */
jpayne@69: void parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Return the length matched by the given affix, or -1 if none.
jpayne@69: * Runs of white space in the affix, match runs of white space in
jpayne@69: * the input.
jpayne@69: * @param affix pattern string, taken as a literal
jpayne@69: * @param input input text
jpayne@69: * @param pos offset into input at which to begin matching
jpayne@69: * @return length of input that matches, or -1 if match failure
jpayne@69: */
jpayne@69: int32_t compareSimpleAffix(const UnicodeString& affix,
jpayne@69: const UnicodeString& input,
jpayne@69: int32_t pos) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Skip over a run of zero or more Pattern_White_Space characters at
jpayne@69: * pos in text.
jpayne@69: */
jpayne@69: int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Skip over a run of zero or more isUWhiteSpace() characters at pos
jpayne@69: * in text.
jpayne@69: */
jpayne@69: int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Initialize LocalizedNumberFormatter instances used for speedup.
jpayne@69: */
jpayne@69: void initFastNumberFormatters(UErrorCode& status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Delete the LocalizedNumberFormatter instances used for speedup.
jpayne@69: */
jpayne@69: void freeFastNumberFormatters();
jpayne@69:
jpayne@69: /**
jpayne@69: * Initialize NumberFormat instances used for numbering system overrides.
jpayne@69: */
jpayne@69: void initNumberFormatters(const Locale &locale,UErrorCode &status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Parse the given override string and set up structures for number formats
jpayne@69: */
jpayne@69: void processOverrideString(const Locale &locale, const UnicodeString &str, int8_t type, UErrorCode &status);
jpayne@69:
jpayne@69: /**
jpayne@69: * Used to map pattern characters to Calendar field identifiers.
jpayne@69: */
jpayne@69: static const UCalendarDateFields fgPatternIndexToCalendarField[];
jpayne@69:
jpayne@69: /**
jpayne@69: * Map index into pattern character string to DateFormat field number
jpayne@69: */
jpayne@69: static const UDateFormatField fgPatternIndexToDateFormatField[];
jpayne@69:
jpayne@69: /**
jpayne@69: * Lazy TimeZoneFormat instantiation, semantically const
jpayne@69: */
jpayne@69: TimeZoneFormat *tzFormat(UErrorCode &status) const;
jpayne@69:
jpayne@69: const NumberFormat* getNumberFormatByIndex(UDateFormatField index) const;
jpayne@69:
jpayne@69: /**
jpayne@69: * Used to map Calendar field to field level.
jpayne@69: * The larger the level, the smaller the field unit.
jpayne@69: * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10,
jpayne@69: * UCAL_MONTH level is 20.
jpayne@69: */
jpayne@69: static const int32_t fgCalendarFieldToLevel[];
jpayne@69:
jpayne@69: /**
jpayne@69: * Map calendar field letter into calendar field level.
jpayne@69: */
jpayne@69: static int32_t getLevelFromChar(char16_t ch);
jpayne@69:
jpayne@69: /**
jpayne@69: * Tell if a character can be used to define a field in a format string.
jpayne@69: */
jpayne@69: static UBool isSyntaxChar(char16_t ch);
jpayne@69:
jpayne@69: /**
jpayne@69: * The formatting pattern for this formatter.
jpayne@69: */
jpayne@69: UnicodeString fPattern;
jpayne@69:
jpayne@69: /**
jpayne@69: * The numbering system override for dates.
jpayne@69: */
jpayne@69: UnicodeString fDateOverride;
jpayne@69:
jpayne@69: /**
jpayne@69: * The numbering system override for times.
jpayne@69: */
jpayne@69: UnicodeString fTimeOverride;
jpayne@69:
jpayne@69:
jpayne@69: /**
jpayne@69: * The original locale used (for reloading symbols)
jpayne@69: */
jpayne@69: Locale fLocale;
jpayne@69:
jpayne@69: /**
jpayne@69: * A pointer to an object containing the strings to use in formatting (e.g.,
jpayne@69: * month and day names, AM and PM strings, time zone names, etc.)
jpayne@69: */
jpayne@69: DateFormatSymbols* fSymbols; // Owned
jpayne@69:
jpayne@69: /**
jpayne@69: * The time zone formatter
jpayne@69: */
jpayne@69: TimeZoneFormat* fTimeZoneFormat;
jpayne@69:
jpayne@69: /**
jpayne@69: * If dates have ambiguous years, we map them into the century starting
jpayne@69: * at defaultCenturyStart, which may be any date. If defaultCenturyStart is
jpayne@69: * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system
jpayne@69: * values are used. The instance values defaultCenturyStart and
jpayne@69: * defaultCenturyStartYear are only used if explicitly set by the user
jpayne@69: * through the API method parseAmbiguousDatesAsAfter().
jpayne@69: */
jpayne@69: UDate fDefaultCenturyStart;
jpayne@69:
jpayne@69: UBool fHasMinute;
jpayne@69: UBool fHasSecond;
jpayne@69: UBool fHasHanYearChar; // pattern contains the Han year character \u5E74
jpayne@69:
jpayne@69: /**
jpayne@69: * Sets fHasMinutes and fHasSeconds.
jpayne@69: */
jpayne@69: void parsePattern();
jpayne@69:
jpayne@69: /**
jpayne@69: * See documentation for defaultCenturyStart.
jpayne@69: */
jpayne@69: /*transient*/ int32_t fDefaultCenturyStartYear;
jpayne@69:
jpayne@69: struct NSOverride : public UMemory {
jpayne@69: const SharedNumberFormat *snf;
jpayne@69: int32_t hash;
jpayne@69: NSOverride *next;
jpayne@69: void free();
jpayne@69: NSOverride() : snf(NULL), hash(0), next(NULL) {
jpayne@69: }
jpayne@69: ~NSOverride();
jpayne@69: };
jpayne@69:
jpayne@69: /**
jpayne@69: * The number format in use for each date field. NULL means fall back
jpayne@69: * to fNumberFormat in DateFormat.
jpayne@69: */
jpayne@69: const SharedNumberFormat **fSharedNumberFormatters;
jpayne@69:
jpayne@69: enum NumberFormatterKey {
jpayne@69: SMPDTFMT_NF_1x10,
jpayne@69: SMPDTFMT_NF_2x10,
jpayne@69: SMPDTFMT_NF_3x10,
jpayne@69: SMPDTFMT_NF_4x10,
jpayne@69: SMPDTFMT_NF_2x2,
jpayne@69: SMPDTFMT_NF_COUNT
jpayne@69: };
jpayne@69:
jpayne@69: /**
jpayne@69: * Number formatters pre-allocated for fast performance on the most common integer lengths.
jpayne@69: */
jpayne@69: const number::LocalizedNumberFormatter* fFastNumberFormatters[SMPDTFMT_NF_COUNT] = {};
jpayne@69:
jpayne@69: UBool fHaveDefaultCentury;
jpayne@69:
jpayne@69: const BreakIterator* fCapitalizationBrkIter;
jpayne@69: };
jpayne@69:
jpayne@69: inline UDate
jpayne@69: SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const
jpayne@69: {
jpayne@69: return fDefaultCenturyStart;
jpayne@69: }
jpayne@69:
jpayne@69: U_NAMESPACE_END
jpayne@69:
jpayne@69: #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69:
jpayne@69: #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69:
jpayne@69: #endif // _SMPDTFMT
jpayne@69: //eof