smpdtfmt.h 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. // Copyright (C) 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. * Copyright (C) 1997-2016, International Business Machines Corporation and
  5. * others. All Rights Reserved.
  6. *******************************************************************************
  7. *
  8. * File SMPDTFMT.H
  9. *
  10. * Modification History:
  11. *
  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
  22. * {j28 4182066}.
  23. *******************************************************************************
  24. */
  25. #ifndef SMPDTFMT_H
  26. #define SMPDTFMT_H
  27. #include "unicode/utypes.h"
  28. /**
  29. * \file
  30. * \brief C++ API: Format and parse dates in a language-independent manner.
  31. */
  32. #if !UCONFIG_NO_FORMATTING
  33. #include "unicode/datefmt.h"
  34. #include "unicode/udisplaycontext.h"
  35. #include "unicode/tzfmt.h" /* for UTimeZoneFormatTimeType */
  36. #include "unicode/brkiter.h"
  37. U_NAMESPACE_BEGIN
  38. class DateFormatSymbols;
  39. class DateFormat;
  40. class MessageFormat;
  41. class FieldPositionHandler;
  42. class TimeZoneFormat;
  43. class SharedNumberFormat;
  44. class SimpleDateFormatMutableNFs;
  45. /**
  46. *
  47. * SimpleDateFormat is a concrete class for formatting and parsing dates in a
  48. * language-independent manner. It allows for formatting (millis -> text),
  49. * parsing (text -> millis), and normalization. Formats/Parses a date or time,
  50. * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970.
  51. * <P>
  52. * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(),
  53. * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than
  54. * explicitly constructing an instance of SimpleDateFormat. This way, the client
  55. * is guaranteed to get an appropriate formatting pattern for whatever locale the
  56. * program is running in. However, if the client needs something more unusual than
  57. * the default patterns in the locales, he can construct a SimpleDateFormat directly
  58. * and give it an appropriate pattern (or use one of the factory methods on DateFormat
  59. * and modify the pattern after the fact with toPattern() and applyPattern().
  60. *
  61. * <p><strong>Date and Time Patterns:</strong></p>
  62. *
  63. * <p>Date and time formats are specified by <em>date and time pattern</em> strings.
  64. * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved
  65. * as pattern letters representing calendar fields. <code>SimpleDateFormat</code> supports
  66. * the date and time formatting algorithm and pattern letters defined by
  67. * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35
  68. * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the
  69. * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table">ICU
  70. * User Guide</a>. The following pattern letters are currently available (note that the actual
  71. * values depend on CLDR and may change from the examples shown here):</p>
  72. *
  73. * <table border="1">
  74. * <tr>
  75. * <th>Field</th>
  76. * <th style="text-align: center">Sym.</th>
  77. * <th style="text-align: center">No.</th>
  78. * <th>Example</th>
  79. * <th>Description</th>
  80. * </tr>
  81. * <tr>
  82. * <th rowspan="3">era</th>
  83. * <td style="text-align: center" rowspan="3">G</td>
  84. * <td style="text-align: center">1..3</td>
  85. * <td>AD</td>
  86. * <td rowspan="3">Era - Replaced with the Era string for the current date. One to three letters for the
  87. * abbreviated form, four letters for the long (wide) form, five for the narrow form.</td>
  88. * </tr>
  89. * <tr>
  90. * <td style="text-align: center">4</td>
  91. * <td>Anno Domini</td>
  92. * </tr>
  93. * <tr>
  94. * <td style="text-align: center">5</td>
  95. * <td>A</td>
  96. * </tr>
  97. * <tr>
  98. * <th rowspan="6">year</th>
  99. * <td style="text-align: center">y</td>
  100. * <td style="text-align: center">1..n</td>
  101. * <td>1996</td>
  102. * <td>Year. Normally the length specifies the padding, but for two letters it also specifies the maximum
  103. * length. Example:<div align="center">
  104. * <center>
  105. * <table border="1" cellpadding="2" cellspacing="0">
  106. * <tr>
  107. * <th>Year</th>
  108. * <th style="text-align: right">y</th>
  109. * <th style="text-align: right">yy</th>
  110. * <th style="text-align: right">yyy</th>
  111. * <th style="text-align: right">yyyy</th>
  112. * <th style="text-align: right">yyyyy</th>
  113. * </tr>
  114. * <tr>
  115. * <td>AD 1</td>
  116. * <td style="text-align: right">1</td>
  117. * <td style="text-align: right">01</td>
  118. * <td style="text-align: right">001</td>
  119. * <td style="text-align: right">0001</td>
  120. * <td style="text-align: right">00001</td>
  121. * </tr>
  122. * <tr>
  123. * <td>AD 12</td>
  124. * <td style="text-align: right">12</td>
  125. * <td style="text-align: right">12</td>
  126. * <td style="text-align: right">012</td>
  127. * <td style="text-align: right">0012</td>
  128. * <td style="text-align: right">00012</td>
  129. * </tr>
  130. * <tr>
  131. * <td>AD 123</td>
  132. * <td style="text-align: right">123</td>
  133. * <td style="text-align: right">23</td>
  134. * <td style="text-align: right">123</td>
  135. * <td style="text-align: right">0123</td>
  136. * <td style="text-align: right">00123</td>
  137. * </tr>
  138. * <tr>
  139. * <td>AD 1234</td>
  140. * <td style="text-align: right">1234</td>
  141. * <td style="text-align: right">34</td>
  142. * <td style="text-align: right">1234</td>
  143. * <td style="text-align: right">1234</td>
  144. * <td style="text-align: right">01234</td>
  145. * </tr>
  146. * <tr>
  147. * <td>AD 12345</td>
  148. * <td style="text-align: right">12345</td>
  149. * <td style="text-align: right">45</td>
  150. * <td style="text-align: right">12345</td>
  151. * <td style="text-align: right">12345</td>
  152. * <td style="text-align: right">12345</td>
  153. * </tr>
  154. * </table>
  155. * </center></div>
  156. * </td>
  157. * </tr>
  158. * <tr>
  159. * <td style="text-align: center">Y</td>
  160. * <td style="text-align: center">1..n</td>
  161. * <td>1997</td>
  162. * <td>Year (in "Week of Year" based calendars). Normally the length specifies the padding,
  163. * but for two letters it also specifies the maximum length. This year designation is used in ISO
  164. * year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems
  165. * where week date processing is desired. May not always be the same value as calendar year.</td>
  166. * </tr>
  167. * <tr>
  168. * <td style="text-align: center">u</td>
  169. * <td style="text-align: center">1..n</td>
  170. * <td>4601</td>
  171. * <td>Extended year. This is a single number designating the year of this calendar system, encompassing
  172. * all supra-year fields. For example, for the Julian calendar system, year numbers are positive, with an
  173. * era of BCE or CE. An extended year value for the Julian calendar system assigns positive values to CE
  174. * years and negative values to BCE years, with 1 BCE being year 0.</td>
  175. * </tr>
  176. * <tr>
  177. * <td style="text-align: center" rowspan="3">U</td>
  178. * <td style="text-align: center">1..3</td>
  179. * <td>&#30002;&#23376;</td>
  180. * <td rowspan="3">Cyclic year name. Calendars such as the Chinese lunar calendar (and related calendars)
  181. * and the Hindu calendars use 60-year cycles of year names. Use one through three letters for the abbreviated
  182. * name, four for the full (wide) name, or five for the narrow name (currently the data only provides abbreviated names,
  183. * which will be used for all requested name widths). If the calendar does not provide cyclic year name data,
  184. * or if the year value to be formatted is out of the range of years for which cyclic name data is provided,
  185. * then numeric formatting is used (behaves like 'y').</td>
  186. * </tr>
  187. * <tr>
  188. * <td style="text-align: center">4</td>
  189. * <td>(currently also &#30002;&#23376;)</td>
  190. * </tr>
  191. * <tr>
  192. * <td style="text-align: center">5</td>
  193. * <td>(currently also &#30002;&#23376;)</td>
  194. * </tr>
  195. * <tr>
  196. * <th rowspan="6">quarter</th>
  197. * <td rowspan="3" style="text-align: center">Q</td>
  198. * <td style="text-align: center">1..2</td>
  199. * <td>02</td>
  200. * <td rowspan="3">Quarter - Use one or two for the numerical quarter, three for the abbreviation, or four for the
  201. * full (wide) name (five for the narrow name is not yet supported).</td>
  202. * </tr>
  203. * <tr>
  204. * <td style="text-align: center">3</td>
  205. * <td>Q2</td>
  206. * </tr>
  207. * <tr>
  208. * <td style="text-align: center">4</td>
  209. * <td>2nd quarter</td>
  210. * </tr>
  211. * <tr>
  212. * <td rowspan="3" style="text-align: center">q</td>
  213. * <td style="text-align: center">1..2</td>
  214. * <td>02</td>
  215. * <td rowspan="3"><b>Stand-Alone</b> Quarter - Use one or two for the numerical quarter, three for the abbreviation,
  216. * or four for the full name (five for the narrow name is not yet supported).</td>
  217. * </tr>
  218. * <tr>
  219. * <td style="text-align: center">3</td>
  220. * <td>Q2</td>
  221. * </tr>
  222. * <tr>
  223. * <td style="text-align: center">4</td>
  224. * <td>2nd quarter</td>
  225. * </tr>
  226. * <tr>
  227. * <th rowspan="8">month</th>
  228. * <td rowspan="4" style="text-align: center">M</td>
  229. * <td style="text-align: center">1..2</td>
  230. * <td>09</td>
  231. * <td rowspan="4">Month - Use one or two for the numerical month, three for the abbreviation, four for
  232. * the full (wide) name, or five for the narrow name. With two ("MM"), the month number is zero-padded
  233. * if necessary (e.g. "08")</td>
  234. * </tr>
  235. * <tr>
  236. * <td style="text-align: center">3</td>
  237. * <td>Sep</td>
  238. * </tr>
  239. * <tr>
  240. * <td style="text-align: center">4</td>
  241. * <td>September</td>
  242. * </tr>
  243. * <tr>
  244. * <td style="text-align: center">5</td>
  245. * <td>S</td>
  246. * </tr>
  247. * <tr>
  248. * <td rowspan="4" style="text-align: center">L</td>
  249. * <td style="text-align: center">1..2</td>
  250. * <td>09</td>
  251. * <td rowspan="4"><b>Stand-Alone</b> Month - Use one or two for the numerical month, three for the abbreviation,
  252. * four for the full (wide) name, or 5 for the narrow name. With two ("LL"), the month number is zero-padded if
  253. * necessary (e.g. "08")</td>
  254. * </tr>
  255. * <tr>
  256. * <td style="text-align: center">3</td>
  257. * <td>Sep</td>
  258. * </tr>
  259. * <tr>
  260. * <td style="text-align: center">4</td>
  261. * <td>September</td>
  262. * </tr>
  263. * <tr>
  264. * <td style="text-align: center">5</td>
  265. * <td>S</td>
  266. * </tr>
  267. * <tr>
  268. * <th rowspan="2">week</th>
  269. * <td style="text-align: center">w</td>
  270. * <td style="text-align: center">1..2</td>
  271. * <td>27</td>
  272. * <td>Week of Year. Use "w" to show the minimum number of digits, or "ww" to always show two digits
  273. * (zero-padding if necessary, e.g. "08").</td>
  274. * </tr>
  275. * <tr>
  276. * <td style="text-align: center">W</td>
  277. * <td style="text-align: center">1</td>
  278. * <td>3</td>
  279. * <td>Week of Month</td>
  280. * </tr>
  281. * <tr>
  282. * <th rowspan="4">day</th>
  283. * <td style="text-align: center">d</td>
  284. * <td style="text-align: center">1..2</td>
  285. * <td>1</td>
  286. * <td>Date - Day of the month. Use "d" to show the minimum number of digits, or "dd" to always show
  287. * two digits (zero-padding if necessary, e.g. "08").</td>
  288. * </tr>
  289. * <tr>
  290. * <td style="text-align: center">D</td>
  291. * <td style="text-align: center">1..3</td>
  292. * <td>345</td>
  293. * <td>Day of year</td>
  294. * </tr>
  295. * <tr>
  296. * <td style="text-align: center">F</td>
  297. * <td style="text-align: center">1</td>
  298. * <td>2</td>
  299. * <td>Day of Week in Month. The example is for the 2nd Wed in July</td>
  300. * </tr>
  301. * <tr>
  302. * <td style="text-align: center">g</td>
  303. * <td style="text-align: center">1..n</td>
  304. * <td>2451334</td>
  305. * <td>Modified Julian day. This is different from the conventional Julian day number in two regards.
  306. * First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number;
  307. * that is, it depends on the local time zone. It can be thought of as a single number that encompasses
  308. * all the date-related fields.</td>
  309. * </tr>
  310. * <tr>
  311. * <th rowspan="14">week<br>
  312. * day</th>
  313. * <td rowspan="4" style="text-align: center">E</td>
  314. * <td style="text-align: center">1..3</td>
  315. * <td>Tue</td>
  316. * <td rowspan="4">Day of week - Use one through three letters for the short day, four for the full (wide) name,
  317. * five for the narrow name, or six for the short name.</td>
  318. * </tr>
  319. * <tr>
  320. * <td style="text-align: center">4</td>
  321. * <td>Tuesday</td>
  322. * </tr>
  323. * <tr>
  324. * <td style="text-align: center">5</td>
  325. * <td>T</td>
  326. * </tr>
  327. * <tr>
  328. * <td style="text-align: center">6</td>
  329. * <td>Tu</td>
  330. * </tr>
  331. * <tr>
  332. * <td rowspan="5" style="text-align: center">e</td>
  333. * <td style="text-align: center">1..2</td>
  334. * <td>2</td>
  335. * <td rowspan="5">Local day of week. Same as E except adds a numeric value that will depend on the local
  336. * starting day of the week, using one or two letters. For this example, Monday is the first day of the week.</td>
  337. * </tr>
  338. * <tr>
  339. * <td style="text-align: center">3</td>
  340. * <td>Tue</td>
  341. * </tr>
  342. * <tr>
  343. * <td style="text-align: center">4</td>
  344. * <td>Tuesday</td>
  345. * </tr>
  346. * <tr>
  347. * <td style="text-align: center">5</td>
  348. * <td>T</td>
  349. * </tr>
  350. * <tr>
  351. * <td style="text-align: center">6</td>
  352. * <td>Tu</td>
  353. * </tr>
  354. * <tr>
  355. * <td rowspan="5" style="text-align: center">c</td>
  356. * <td style="text-align: center">1</td>
  357. * <td>2</td>
  358. * <td rowspan="5"><b>Stand-Alone</b> local day of week - Use one letter for the local numeric value (same
  359. * as 'e'), three for the short day, four for the full (wide) name, five for the narrow name, or six for
  360. * the short name.</td>
  361. * </tr>
  362. * <tr>
  363. * <td style="text-align: center">3</td>
  364. * <td>Tue</td>
  365. * </tr>
  366. * <tr>
  367. * <td style="text-align: center">4</td>
  368. * <td>Tuesday</td>
  369. * </tr>
  370. * <tr>
  371. * <td style="text-align: center">5</td>
  372. * <td>T</td>
  373. * </tr>
  374. * <tr>
  375. * <td style="text-align: center">6</td>
  376. * <td>Tu</td>
  377. * </tr>
  378. * <tr>
  379. * <th>period</th>
  380. * <td style="text-align: center">a</td>
  381. * <td style="text-align: center">1</td>
  382. * <td>AM</td>
  383. * <td>AM or PM</td>
  384. * </tr>
  385. * <tr>
  386. * <th rowspan="4">hour</th>
  387. * <td style="text-align: center">h</td>
  388. * <td style="text-align: center">1..2</td>
  389. * <td>11</td>
  390. * <td>Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern
  391. * generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match
  392. * a 24-hour-cycle format (H or k). Use hh for zero padding.</td>
  393. * </tr>
  394. * <tr>
  395. * <td style="text-align: center">H</td>
  396. * <td style="text-align: center">1..2</td>
  397. * <td>13</td>
  398. * <td>Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern
  399. * generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a
  400. * 12-hour-cycle format (h or K). Use HH for zero padding.</td>
  401. * </tr>
  402. * <tr>
  403. * <td style="text-align: center">K</td>
  404. * <td style="text-align: center">1..2</td>
  405. * <td>0</td>
  406. * <td>Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding.</td>
  407. * </tr>
  408. * <tr>
  409. * <td style="text-align: center">k</td>
  410. * <td style="text-align: center">1..2</td>
  411. * <td>24</td>
  412. * <td>Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding.</td>
  413. * </tr>
  414. * <tr>
  415. * <th>minute</th>
  416. * <td style="text-align: center">m</td>
  417. * <td style="text-align: center">1..2</td>
  418. * <td>59</td>
  419. * <td>Minute. Use "m" to show the minimum number of digits, or "mm" to always show two digits
  420. * (zero-padding if necessary, e.g. "08").</td>
  421. * </tr>
  422. * <tr>
  423. * <th rowspan="3">second</th>
  424. * <td style="text-align: center">s</td>
  425. * <td style="text-align: center">1..2</td>
  426. * <td>12</td>
  427. * <td>Second. Use "s" to show the minimum number of digits, or "ss" to always show two digits
  428. * (zero-padding if necessary, e.g. "08").</td>
  429. * </tr>
  430. * <tr>
  431. * <td style="text-align: center">S</td>
  432. * <td style="text-align: center">1..n</td>
  433. * <td>3450</td>
  434. * <td>Fractional Second - truncates (like other time fields) to the count of letters when formatting.
  435. * Appends zeros if more than 3 letters specified. Truncates at three significant digits when parsing.
  436. * (example shows display using pattern SSSS for seconds value 12.34567)</td>
  437. * </tr>
  438. * <tr>
  439. * <td style="text-align: center">A</td>
  440. * <td style="text-align: center">1..n</td>
  441. * <td>69540000</td>
  442. * <td>Milliseconds in day. This field behaves <i>exactly</i> like a composite of all time-related fields,
  443. * not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition
  444. * days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This
  445. * reflects the fact that is must be combined with the offset field to obtain a unique local time value.</td>
  446. * </tr>
  447. * <tr>
  448. * <th rowspan="23">zone</th>
  449. * <td rowspan="2" style="text-align: center">z</td>
  450. * <td style="text-align: center">1..3</td>
  451. * <td>PDT</td>
  452. * <td>The <i>short specific non-location format</i>.
  453. * Where that is unavailable, falls back to the <i>short localized GMT format</i> ("O").</td>
  454. * </tr>
  455. * <tr>
  456. * <td style="text-align: center">4</td>
  457. * <td>Pacific Daylight Time</td>
  458. * <td>The <i>long specific non-location format</i>.
  459. * Where that is unavailable, falls back to the <i>long localized GMT format</i> ("OOOO").</td>
  460. * </tr>
  461. * <tr>
  462. * <td rowspan="3" style="text-align: center">Z</td>
  463. * <td style="text-align: center">1..3</td>
  464. * <td>-0800</td>
  465. * <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields.
  466. * The format is equivalent to RFC 822 zone format (when optional seconds field is absent).
  467. * This is equivalent to the "xxxx" specifier.</td>
  468. * </tr>
  469. * <tr>
  470. * <td style="text-align: center">4</td>
  471. * <td>GMT-8:00</td>
  472. * <td>The <i>long localized GMT format</i>.
  473. * This is equivalent to the "OOOO" specifier.</td>
  474. * </tr>
  475. * <tr>
  476. * <td style="text-align: center">5</td>
  477. * <td>-08:00<br>
  478. * -07:52:58</td>
  479. * <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields.
  480. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.
  481. * This is equivalent to the "XXXXX" specifier.</td>
  482. * </tr>
  483. * <tr>
  484. * <td rowspan="2" style="text-align: center">O</td>
  485. * <td style="text-align: center">1</td>
  486. * <td>GMT-8</td>
  487. * <td>The <i>short localized GMT format</i>.</td>
  488. * </tr>
  489. * <tr>
  490. * <td style="text-align: center">4</td>
  491. * <td>GMT-08:00</td>
  492. * <td>The <i>long localized GMT format</i>.</td>
  493. * </tr>
  494. * <tr>
  495. * <td rowspan="2" style="text-align: center">v</td>
  496. * <td style="text-align: center">1</td>
  497. * <td>PT</td>
  498. * <td>The <i>short generic non-location format</i>.
  499. * Where that is unavailable, falls back to the <i>generic location format</i> ("VVVV"),
  500. * then the <i>short localized GMT format</i> as the final fallback.</td>
  501. * </tr>
  502. * <tr>
  503. * <td style="text-align: center">4</td>
  504. * <td>Pacific Time</td>
  505. * <td>The <i>long generic non-location format</i>.
  506. * Where that is unavailable, falls back to <i>generic location format</i> ("VVVV").
  507. * </tr>
  508. * <tr>
  509. * <td rowspan="4" style="text-align: center">V</td>
  510. * <td style="text-align: center">1</td>
  511. * <td>uslax</td>
  512. * <td>The short time zone ID.
  513. * Where that is unavailable, the special short time zone ID <i>unk</i> (Unknown Zone) is used.<br>
  514. * <i><b>Note</b>: This specifier was originally used for a variant of the short specific non-location format,
  515. * but it was deprecated in the later version of the LDML specification. In CLDR 23/ICU 51, the definition of
  516. * the specifier was changed to designate a short time zone ID.</i></td>
  517. * </tr>
  518. * <tr>
  519. * <td style="text-align: center">2</td>
  520. * <td>America/Los_Angeles</td>
  521. * <td>The long time zone ID.</td>
  522. * </tr>
  523. * <tr>
  524. * <td style="text-align: center">3</td>
  525. * <td>Los Angeles</td>
  526. * <td>The exemplar city (location) for the time zone.
  527. * Where that is unavailable, the localized exemplar city name for the special zone <i>Etc/Unknown</i> is used
  528. * as the fallback (for example, "Unknown City"). </td>
  529. * </tr>
  530. * <tr>
  531. * <td style="text-align: center">4</td>
  532. * <td>Los Angeles Time</td>
  533. * <td>The <i>generic location format</i>.
  534. * Where that is unavailable, falls back to the <i>long localized GMT format</i> ("OOOO";
  535. * Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.)<br>
  536. * This is especially useful when presenting possible timezone choices for user selection,
  537. * since the naming is more uniform than the "v" format.</td>
  538. * </tr>
  539. * <tr>
  540. * <td rowspan="5" style="text-align: center">X</td>
  541. * <td style="text-align: center">1</td>
  542. * <td>-08<br>
  543. * +0530<br>
  544. * Z</td>
  545. * <td>The <i>ISO8601 basic format</i> with hours field and optional minutes field.
  546. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td>
  547. * </tr>
  548. * <tr>
  549. * <td style="text-align: center">2</td>
  550. * <td>-0800<br>
  551. * Z</td>
  552. * <td>The <i>ISO8601 basic format</i> with hours and minutes fields.
  553. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td>
  554. * </tr>
  555. * <tr>
  556. * <td style="text-align: center">3</td>
  557. * <td>-08:00<br>
  558. * Z</td>
  559. * <td>The <i>ISO8601 extended format</i> with hours and minutes fields.
  560. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td>
  561. * </tr>
  562. * <tr>
  563. * <td style="text-align: center">4</td>
  564. * <td>-0800<br>
  565. * -075258<br>
  566. * Z</td>
  567. * <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields.
  568. * (Note: The seconds field is not supported by the ISO8601 specification.)
  569. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td>
  570. * </tr>
  571. * <tr>
  572. * <td style="text-align: center">5</td>
  573. * <td>-08:00<br>
  574. * -07:52:58<br>
  575. * Z</td>
  576. * <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields.
  577. * (Note: The seconds field is not supported by the ISO8601 specification.)
  578. * The ISO8601 UTC indicator "Z" is used when local time offset is 0.</td>
  579. * </tr>
  580. * <tr>
  581. * <td rowspan="5" style="text-align: center">x</td>
  582. * <td style="text-align: center">1</td>
  583. * <td>-08<br>
  584. * +0530</td>
  585. * <td>The <i>ISO8601 basic format</i> with hours field and optional minutes field.</td>
  586. * </tr>
  587. * <tr>
  588. * <td style="text-align: center">2</td>
  589. * <td>-0800</td>
  590. * <td>The <i>ISO8601 basic format</i> with hours and minutes fields.</td>
  591. * </tr>
  592. * <tr>
  593. * <td style="text-align: center">3</td>
  594. * <td>-08:00</td>
  595. * <td>The <i>ISO8601 extended format</i> with hours and minutes fields.</td>
  596. * </tr>
  597. * <tr>
  598. * <td style="text-align: center">4</td>
  599. * <td>-0800<br>
  600. * -075258</td>
  601. * <td>The <i>ISO8601 basic format</i> with hours, minutes and optional seconds fields.
  602. * (Note: The seconds field is not supported by the ISO8601 specification.)</td>
  603. * </tr>
  604. * <tr>
  605. * <td style="text-align: center">5</td>
  606. * <td>-08:00<br>
  607. * -07:52:58</td>
  608. * <td>The <i>ISO8601 extended format</i> with hours, minutes and optional seconds fields.
  609. * (Note: The seconds field is not supported by the ISO8601 specification.)</td>
  610. * </tr>
  611. * </table>
  612. *
  613. * <P>
  614. * Any characters in the pattern that are not in the ranges of ['a'..'z'] and
  615. * ['A'..'Z'] will be treated as quoted text. For instance, characters
  616. * like ':', '.', ' ', '#' and '@' will appear in the resulting time text
  617. * even they are not embraced within single quotes.
  618. * <P>
  619. * A pattern containing any invalid pattern letter will result in a failing
  620. * UErrorCode result during formatting or parsing.
  621. * <P>
  622. * Examples using the US locale:
  623. * <pre>
  624. * \code
  625. * Format Pattern Result
  626. * -------------- -------
  627. * "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->> 1996.07.10 AD at 15:08:56 Pacific Time
  628. * "EEE, MMM d, ''yy" ->> Wed, July 10, '96
  629. * "h:mm a" ->> 12:08 PM
  630. * "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
  631. * "K:mm a, vvv" ->> 0:00 PM, PT
  632. * "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM
  633. * \endcode
  634. * </pre>
  635. * Code Sample:
  636. * <pre>
  637. * \code
  638. * UErrorCode success = U_ZERO_ERROR;
  639. * SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
  640. * pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);
  641. * pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);
  642. *
  643. * // Format the current time.
  644. * SimpleDateFormat* formatter
  645. * = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success );
  646. * GregorianCalendar cal(success);
  647. * UDate currentTime_1 = cal.getTime(success);
  648. * FieldPosition fp(FieldPosition::DONT_CARE);
  649. * UnicodeString dateString;
  650. * formatter->format( currentTime_1, dateString, fp );
  651. * cout << "result: " << dateString << endl;
  652. *
  653. * // Parse the previous string back into a Date.
  654. * ParsePosition pp(0);
  655. * UDate currentTime_2 = formatter->parse(dateString, pp );
  656. * \endcode
  657. * </pre>
  658. * In the above example, the time value "currentTime_2" obtained from parsing
  659. * will be equal to currentTime_1. However, they may not be equal if the am/pm
  660. * marker 'a' is left out from the format pattern while the "hour in am/pm"
  661. * pattern symbol is used. This information loss can happen when formatting the
  662. * time in PM.
  663. *
  664. * <p>
  665. * When parsing a date string using the abbreviated year pattern ("y" or "yy"),
  666. * SimpleDateFormat must interpret the abbreviated year
  667. * relative to some century. It does this by adjusting dates to be
  668. * within 80 years before and 20 years after the time the SimpleDateFormat
  669. * instance is created. For example, using a pattern of "MM/dd/yy" and a
  670. * SimpleDateFormat instance created on Jan 1, 1997, the string
  671. * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64"
  672. * would be interpreted as May 4, 1964.
  673. * During parsing, only strings consisting of exactly two digits, as defined by
  674. * <code>Unicode::isDigit()</code>, will be parsed into the default century.
  675. * Any other numeric string, such as a one digit string, a three or more digit
  676. * string, or a two digit string that isn't all digits (for example, "-1"), is
  677. * interpreted literally. So "01/02/3" or "01/02/003" are parsed (for the
  678. * Gregorian calendar), using the same pattern, as Jan 2, 3 AD. Likewise (but
  679. * only in lenient parse mode, the default) "01/02/-3" is parsed as Jan 2, 4 BC.
  680. *
  681. * <p>
  682. * If the year pattern has more than two 'y' characters, the year is
  683. * interpreted literally, regardless of the number of digits. So using the
  684. * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
  685. *
  686. * <p>
  687. * When numeric fields abut one another directly, with no intervening delimiter
  688. * characters, they constitute a run of abutting numeric fields. Such runs are
  689. * parsed specially. For example, the format "HHmmss" parses the input text
  690. * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to
  691. * parse "1234". In other words, the leftmost field of the run is flexible,
  692. * while the others keep a fixed width. If the parse fails anywhere in the run,
  693. * then the leftmost field is shortened by one character, and the entire run is
  694. * parsed again. This is repeated until either the parse succeeds or the
  695. * leftmost field is one character in length. If the parse still fails at that
  696. * point, the parse of the run fails.
  697. *
  698. * <P>
  699. * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or
  700. * GMT-hours:minutes.
  701. * <P>
  702. * The calendar defines what is the first day of the week, the first week of the
  703. * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone.
  704. * There is one common number format to handle all the numbers; the digit count
  705. * is handled programmatically according to the pattern.
  706. *
  707. * <p><em>User subclasses are not supported.</em> While clients may write
  708. * subclasses, such code will not necessarily work and will not be
  709. * guaranteed to work stably from release to release.
  710. */
  711. class U_I18N_API SimpleDateFormat: public DateFormat {
  712. public:
  713. /**
  714. * Construct a SimpleDateFormat using the default pattern for the default
  715. * locale.
  716. * <P>
  717. * [Note:] Not all locales support SimpleDateFormat; for full generality,
  718. * use the factory methods in the DateFormat class.
  719. * @param status Output param set to success/failure code.
  720. * @stable ICU 2.0
  721. */
  722. SimpleDateFormat(UErrorCode& status);
  723. /**
  724. * Construct a SimpleDateFormat using the given pattern and the default locale.
  725. * The locale is used to obtain the symbols used in formatting (e.g., the
  726. * names of the months), but not to provide the pattern.
  727. * <P>
  728. * [Note:] Not all locales support SimpleDateFormat; for full generality,
  729. * use the factory methods in the DateFormat class.
  730. * @param pattern the pattern for the format.
  731. * @param status Output param set to success/failure code.
  732. * @stable ICU 2.0
  733. */
  734. SimpleDateFormat(const UnicodeString& pattern,
  735. UErrorCode& status);
  736. /**
  737. * Construct a SimpleDateFormat using the given pattern, numbering system override, and the default locale.
  738. * The locale is used to obtain the symbols used in formatting (e.g., the
  739. * names of the months), but not to provide the pattern.
  740. * <P>
  741. * A numbering system override is a string containing either the name of a known numbering system,
  742. * or a set of field and numbering system pairs that specify which fields are to be formattied with
  743. * the alternate numbering system. For example, to specify that all numeric fields in the specified
  744. * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override
  745. * as "thai". To specify that just the year portion of the date be formatted using Hebrew numbering,
  746. * use the override string "y=hebrew". Numbering system overrides can be combined using a semi-colon
  747. * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc.
  748. *
  749. * <P>
  750. * [Note:] Not all locales support SimpleDateFormat; for full generality,
  751. * use the factory methods in the DateFormat class.
  752. * @param pattern the pattern for the format.
  753. * @param override the override string.
  754. * @param status Output param set to success/failure code.
  755. * @stable ICU 4.2
  756. */
  757. SimpleDateFormat(const UnicodeString& pattern,
  758. const UnicodeString& override,
  759. UErrorCode& status);
  760. /**
  761. * Construct a SimpleDateFormat using the given pattern and locale.
  762. * The locale is used to obtain the symbols used in formatting (e.g., the
  763. * names of the months), but not to provide the pattern.
  764. * <P>
  765. * [Note:] Not all locales support SimpleDateFormat; for full generality,
  766. * use the factory methods in the DateFormat class.
  767. * @param pattern the pattern for the format.
  768. * @param locale the given locale.
  769. * @param status Output param set to success/failure code.
  770. * @stable ICU 2.0
  771. */
  772. SimpleDateFormat(const UnicodeString& pattern,
  773. const Locale& locale,
  774. UErrorCode& status);
  775. /**
  776. * Construct a SimpleDateFormat using the given pattern, numbering system override, and locale.
  777. * The locale is used to obtain the symbols used in formatting (e.g., the
  778. * names of the months), but not to provide the pattern.
  779. * <P>
  780. * A numbering system override is a string containing either the name of a known numbering system,
  781. * or a set of field and numbering system pairs that specify which fields are to be formattied with
  782. * the alternate numbering system. For example, to specify that all numeric fields in the specified
  783. * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override
  784. * as "thai". To specify that just the year portion of the date be formatted using Hebrew numbering,
  785. * use the override string "y=hebrew". Numbering system overrides can be combined using a semi-colon
  786. * character in the override string, such as "d=decimal;M=arabic;y=hebrew", etc.
  787. * <P>
  788. * [Note:] Not all locales support SimpleDateFormat; for full generality,
  789. * use the factory methods in the DateFormat class.
  790. * @param pattern the pattern for the format.
  791. * @param override the numbering system override.
  792. * @param locale the given locale.
  793. * @param status Output param set to success/failure code.
  794. * @stable ICU 4.2
  795. */
  796. SimpleDateFormat(const UnicodeString& pattern,
  797. const UnicodeString& override,
  798. const Locale& locale,
  799. UErrorCode& status);
  800. /**
  801. * Construct a SimpleDateFormat using the given pattern and locale-specific
  802. * symbol data. The formatter takes ownership of the DateFormatSymbols object;
  803. * the caller is no longer responsible for deleting it.
  804. * @param pattern the given pattern for the format.
  805. * @param formatDataToAdopt the symbols to be adopted.
  806. * @param status Output param set to success/faulure code.
  807. * @stable ICU 2.0
  808. */
  809. SimpleDateFormat(const UnicodeString& pattern,
  810. DateFormatSymbols* formatDataToAdopt,
  811. UErrorCode& status);
  812. /**
  813. * Construct a SimpleDateFormat using the given pattern and locale-specific
  814. * symbol data. The DateFormatSymbols object is NOT adopted; the caller
  815. * remains responsible for deleting it.
  816. * @param pattern the given pattern for the format.
  817. * @param formatData the formatting symbols to be use.
  818. * @param status Output param set to success/faulure code.
  819. * @stable ICU 2.0
  820. */
  821. SimpleDateFormat(const UnicodeString& pattern,
  822. const DateFormatSymbols& formatData,
  823. UErrorCode& status);
  824. /**
  825. * Copy constructor.
  826. * @stable ICU 2.0
  827. */
  828. SimpleDateFormat(const SimpleDateFormat&);
  829. /**
  830. * Assignment operator.
  831. * @stable ICU 2.0
  832. */
  833. SimpleDateFormat& operator=(const SimpleDateFormat&);
  834. /**
  835. * Destructor.
  836. * @stable ICU 2.0
  837. */
  838. virtual ~SimpleDateFormat();
  839. /**
  840. * Clone this Format object polymorphically. The caller owns the result and
  841. * should delete it when done.
  842. * @return A copy of the object.
  843. * @stable ICU 2.0
  844. */
  845. virtual Format* clone(void) const;
  846. /**
  847. * Return true if the given Format objects are semantically equal. Objects
  848. * of different subclasses are considered unequal.
  849. * @param other the object to be compared with.
  850. * @return true if the given Format objects are semantically equal.
  851. * @stable ICU 2.0
  852. */
  853. virtual UBool operator==(const Format& other) const;
  854. using DateFormat::format;
  855. /**
  856. * Format a date or time, which is the standard millis since 24:00 GMT, Jan
  857. * 1, 1970. Overrides DateFormat pure virtual method.
  858. * <P>
  859. * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
  860. * 1996.07.10 AD at 15:08:56 PDT
  861. *
  862. * @param cal Calendar set to the date and time to be formatted
  863. * into a date/time string.
  864. * @param appendTo Output parameter to receive result.
  865. * Result is appended to existing contents.
  866. * @param pos The formatting position. On input: an alignment field,
  867. * if desired. On output: the offsets of the alignment field.
  868. * @return Reference to 'appendTo' parameter.
  869. * @stable ICU 2.1
  870. */
  871. virtual UnicodeString& format( Calendar& cal,
  872. UnicodeString& appendTo,
  873. FieldPosition& pos) const;
  874. /**
  875. * Format a date or time, which is the standard millis since 24:00 GMT, Jan
  876. * 1, 1970. Overrides DateFormat pure virtual method.
  877. * <P>
  878. * Example: using the US locale: "yyyy.MM.dd e 'at' HH:mm:ss zzz" ->>
  879. * 1996.07.10 AD at 15:08:56 PDT
  880. *
  881. * @param cal Calendar set to the date and time to be formatted
  882. * into a date/time string.
  883. * @param appendTo Output parameter to receive result.
  884. * Result is appended to existing contents.
  885. * @param posIter On return, can be used to iterate over positions
  886. * of fields generated by this format call. Field values
  887. * are defined in UDateFormatField.
  888. * @param status Input/output param set to success/failure code.
  889. * @return Reference to 'appendTo' parameter.
  890. * @stable ICU 4.4
  891. */
  892. virtual UnicodeString& format( Calendar& cal,
  893. UnicodeString& appendTo,
  894. FieldPositionIterator* posIter,
  895. UErrorCode& status) const;
  896. using DateFormat::parse;
  897. /**
  898. * Parse a date/time string beginning at the given parse position. For
  899. * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
  900. * that is equivalent to Date(837039928046).
  901. * <P>
  902. * By default, parsing is lenient: If the input is not in the form used by
  903. * this object's format method but can still be parsed as a date, then the
  904. * parse succeeds. Clients may insist on strict adherence to the format by
  905. * calling setLenient(false).
  906. * @see DateFormat::setLenient(boolean)
  907. *
  908. * @param text The date/time string to be parsed
  909. * @param cal A Calendar set on input to the date and time to be used for
  910. * missing values in the date/time string being parsed, and set
  911. * on output to the parsed date/time. When the calendar type is
  912. * different from the internal calendar held by this SimpleDateFormat
  913. * instance, the internal calendar will be cloned to a work
  914. * calendar set to the same milliseconds and time zone as the
  915. * cal parameter, field values will be parsed based on the work
  916. * calendar, then the result (milliseconds and time zone) will
  917. * be set in this calendar.
  918. * @param pos On input, the position at which to start parsing; on
  919. * output, the position at which parsing terminated, or the
  920. * start position if the parse failed.
  921. * @stable ICU 2.1
  922. */
  923. virtual void parse( const UnicodeString& text,
  924. Calendar& cal,
  925. ParsePosition& pos) const;
  926. /**
  927. * Set the start UDate used to interpret two-digit year strings.
  928. * When dates are parsed having 2-digit year strings, they are placed within
  929. * a assumed range of 100 years starting on the two digit start date. For
  930. * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
  931. * some other year. SimpleDateFormat chooses a year so that the resultant
  932. * date is on or after the two digit start date and within 100 years of the
  933. * two digit start date.
  934. * <P>
  935. * By default, the two digit start date is set to 80 years before the current
  936. * time at which a SimpleDateFormat object is created.
  937. * @param d start UDate used to interpret two-digit year strings.
  938. * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
  939. * an error value if there was a parse error.
  940. * @stable ICU 2.0
  941. */
  942. virtual void set2DigitYearStart(UDate d, UErrorCode& status);
  943. /**
  944. * Get the start UDate used to interpret two-digit year strings.
  945. * When dates are parsed having 2-digit year strings, they are placed within
  946. * a assumed range of 100 years starting on the two digit start date. For
  947. * example, the string "24-Jan-17" may be in the year 1817, 1917, 2017, or
  948. * some other year. SimpleDateFormat chooses a year so that the resultant
  949. * date is on or after the two digit start date and within 100 years of the
  950. * two digit start date.
  951. * <P>
  952. * By default, the two digit start date is set to 80 years before the current
  953. * time at which a SimpleDateFormat object is created.
  954. * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with
  955. * an error value if there was a parse error.
  956. * @stable ICU 2.0
  957. */
  958. UDate get2DigitYearStart(UErrorCode& status) const;
  959. /**
  960. * Return a pattern string describing this date format.
  961. * @param result Output param to receive the pattern.
  962. * @return A reference to 'result'.
  963. * @stable ICU 2.0
  964. */
  965. virtual UnicodeString& toPattern(UnicodeString& result) const;
  966. /**
  967. * Return a localized pattern string describing this date format.
  968. * In most cases, this will return the same thing as toPattern(),
  969. * but a locale can specify characters to use in pattern descriptions
  970. * in place of the ones described in this class's class documentation.
  971. * (Presumably, letters that would be more mnemonic in that locale's
  972. * language.) This function would produce a pattern using those
  973. * letters.
  974. * <p>
  975. * <b>Note:</b> This implementation depends on DateFormatSymbols::getLocalPatternChars()
  976. * to get localized format pattern characters. ICU does not include
  977. * localized pattern character data, therefore, unless user sets localized
  978. * pattern characters manually, this method returns the same result as
  979. * toPattern().
  980. *
  981. * @param result Receives the localized pattern.
  982. * @param status Output param set to success/failure code on
  983. * exit. If the pattern is invalid, this will be
  984. * set to a failure result.
  985. * @return A reference to 'result'.
  986. * @stable ICU 2.0
  987. */
  988. virtual UnicodeString& toLocalizedPattern(UnicodeString& result,
  989. UErrorCode& status) const;
  990. /**
  991. * Apply the given unlocalized pattern string to this date format.
  992. * (i.e., after this call, this formatter will format dates according to
  993. * the new pattern)
  994. *
  995. * @param pattern The pattern to be applied.
  996. * @stable ICU 2.0
  997. */
  998. virtual void applyPattern(const UnicodeString& pattern);
  999. /**
  1000. * Apply the given localized pattern string to this date format.
  1001. * (see toLocalizedPattern() for more information on localized patterns.)
  1002. *
  1003. * @param pattern The localized pattern to be applied.
  1004. * @param status Output param set to success/failure code on
  1005. * exit. If the pattern is invalid, this will be
  1006. * set to a failure result.
  1007. * @stable ICU 2.0
  1008. */
  1009. virtual void applyLocalizedPattern(const UnicodeString& pattern,
  1010. UErrorCode& status);
  1011. /**
  1012. * Gets the date/time formatting symbols (this is an object carrying
  1013. * the various strings and other symbols used in formatting: e.g., month
  1014. * names and abbreviations, time zone names, AM/PM strings, etc.)
  1015. * @return a copy of the date-time formatting data associated
  1016. * with this date-time formatter.
  1017. * @stable ICU 2.0
  1018. */
  1019. virtual const DateFormatSymbols* getDateFormatSymbols(void) const;
  1020. /**
  1021. * Set the date/time formatting symbols. The caller no longer owns the
  1022. * DateFormatSymbols object and should not delete it after making this call.
  1023. * @param newFormatSymbols the given date-time formatting symbols to copy.
  1024. * @stable ICU 2.0
  1025. */
  1026. virtual void adoptDateFormatSymbols(DateFormatSymbols* newFormatSymbols);
  1027. /**
  1028. * Set the date/time formatting data.
  1029. * @param newFormatSymbols the given date-time formatting symbols to copy.
  1030. * @stable ICU 2.0
  1031. */
  1032. virtual void setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols);
  1033. /**
  1034. * Return the class ID for this class. This is useful only for comparing to
  1035. * a return value from getDynamicClassID(). For example:
  1036. * <pre>
  1037. * . Base* polymorphic_pointer = createPolymorphicObject();
  1038. * . if (polymorphic_pointer->getDynamicClassID() ==
  1039. * . erived::getStaticClassID()) ...
  1040. * </pre>
  1041. * @return The class ID for all objects of this class.
  1042. * @stable ICU 2.0
  1043. */
  1044. static UClassID U_EXPORT2 getStaticClassID(void);
  1045. /**
  1046. * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
  1047. * method is to implement a simple version of RTTI, since not all C++
  1048. * compilers support genuine RTTI. Polymorphic operator==() and clone()
  1049. * methods call this method.
  1050. *
  1051. * @return The class ID for this object. All objects of a
  1052. * given class have the same class ID. Objects of
  1053. * other classes have different class IDs.
  1054. * @stable ICU 2.0
  1055. */
  1056. virtual UClassID getDynamicClassID(void) const;
  1057. /**
  1058. * Set the calendar to be used by this date format. Initially, the default
  1059. * calendar for the specified or default locale is used. The caller should
  1060. * not delete the Calendar object after it is adopted by this call.
  1061. * Adopting a new calendar will change to the default symbols.
  1062. *
  1063. * @param calendarToAdopt Calendar object to be adopted.
  1064. * @stable ICU 2.0
  1065. */
  1066. virtual void adoptCalendar(Calendar* calendarToAdopt);
  1067. /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since they are virtual */
  1068. /**
  1069. * Sets the TimeZoneFormat to be used by this date/time formatter.
  1070. * The caller should not delete the TimeZoneFormat object after
  1071. * it is adopted by this call.
  1072. * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted.
  1073. * @internal ICU 49 technology preview
  1074. */
  1075. virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt);
  1076. /**
  1077. * Sets the TimeZoneFormat to be used by this date/time formatter.
  1078. * @param newTimeZoneFormat The TimeZoneFormat object to copy.
  1079. * @internal ICU 49 technology preview
  1080. */
  1081. virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat);
  1082. /**
  1083. * Gets the time zone format object associated with this date/time formatter.
  1084. * @return the time zone format associated with this date/time formatter.
  1085. * @internal ICU 49 technology preview
  1086. */
  1087. virtual const TimeZoneFormat* getTimeZoneFormat(void) const;
  1088. /**
  1089. * Set a particular UDisplayContext value in the formatter, such as
  1090. * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see
  1091. * DateFormat.
  1092. * @param value The UDisplayContext value to set.
  1093. * @param status Input/output status. If at entry this indicates a failure
  1094. * status, the function will do nothing; otherwise this will be
  1095. * updated with any new status from the function.
  1096. * @stable ICU 53
  1097. */
  1098. virtual void setContext(UDisplayContext value, UErrorCode& status);
  1099. /**
  1100. * Overrides base class method and
  1101. * This method clears per field NumberFormat instances
  1102. * previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFormat*, UErrorCode)}
  1103. * @param adoptNF the NumbeferFormat used
  1104. * @stable ICU 54
  1105. */
  1106. void adoptNumberFormat(NumberFormat *formatToAdopt);
  1107. /**
  1108. * Allow the user to set the NumberFormat for several fields
  1109. * It can be a single field like: "y"(year) or "M"(month)
  1110. * It can be several field combined together: "yM"(year and month)
  1111. * Note:
  1112. * 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy")
  1113. * If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field)
  1114. * Per field NumberFormat can also be cleared in {@see DateFormat::setNumberFormat(const NumberFormat& newNumberFormat)}
  1115. *
  1116. * @param fields the fields to override(like y)
  1117. * @param adoptNF the NumbeferFormat used
  1118. * @param status Receives a status code, which will be U_ZERO_ERROR
  1119. * if the operation succeeds.
  1120. * @stable ICU 54
  1121. */
  1122. void adoptNumberFormat(const UnicodeString& fields, NumberFormat *formatToAdopt, UErrorCode &status);
  1123. /**
  1124. * Get the numbering system to be used for a particular field.
  1125. * @param field The UDateFormatField to get
  1126. * @stable ICU 54
  1127. */
  1128. const NumberFormat * getNumberFormatForField(UChar field) const;
  1129. #ifndef U_HIDE_INTERNAL_API
  1130. /**
  1131. * This is for ICU internal use only. Please do not use.
  1132. * Check whether the 'field' is smaller than all the fields covered in
  1133. * pattern, return TRUE if it is. The sequence of calendar field,
  1134. * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
  1135. * @param field the calendar field need to check against
  1136. * @return TRUE if the 'field' is smaller than all the fields
  1137. * covered in pattern. FALSE otherwise.
  1138. * @internal ICU 4.0
  1139. */
  1140. UBool isFieldUnitIgnored(UCalendarDateFields field) const;
  1141. /**
  1142. * This is for ICU internal use only. Please do not use.
  1143. * Check whether the 'field' is smaller than all the fields covered in
  1144. * pattern, return TRUE if it is. The sequence of calendar field,
  1145. * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
  1146. * @param pattern the pattern to check against
  1147. * @param field the calendar field need to check against
  1148. * @return TRUE if the 'field' is smaller than all the fields
  1149. * covered in pattern. FALSE otherwise.
  1150. * @internal ICU 4.0
  1151. */
  1152. static UBool isFieldUnitIgnored(const UnicodeString& pattern,
  1153. UCalendarDateFields field);
  1154. /**
  1155. * This is for ICU internal use only. Please do not use.
  1156. * Get the locale of this simple date formatter.
  1157. * It is used in DateIntervalFormat.
  1158. *
  1159. * @return locale in this simple date formatter
  1160. * @internal ICU 4.0
  1161. */
  1162. const Locale& getSmpFmtLocale(void) const;
  1163. #endif /* U_HIDE_INTERNAL_API */
  1164. private:
  1165. friend class DateFormat;
  1166. void initializeDefaultCentury(void);
  1167. void initializeBooleanAttributes(void);
  1168. SimpleDateFormat(); // default constructor not implemented
  1169. /**
  1170. * Used by the DateFormat factory methods to construct a SimpleDateFormat.
  1171. * @param timeStyle the time style.
  1172. * @param dateStyle the date style.
  1173. * @param locale the given locale.
  1174. * @param status Output param set to success/failure code on
  1175. * exit.
  1176. */
  1177. SimpleDateFormat(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
  1178. /**
  1179. * Construct a SimpleDateFormat for the given locale. If no resource data
  1180. * is available, create an object of last resort, using hard-coded strings.
  1181. * This is an internal method, called by DateFormat. It should never fail.
  1182. * @param locale the given locale.
  1183. * @param status Output param set to success/failure code on
  1184. * exit.
  1185. */
  1186. SimpleDateFormat(const Locale& locale, UErrorCode& status); // Use default pattern
  1187. /**
  1188. * Hook called by format(... FieldPosition& ...) and format(...FieldPositionIterator&...)
  1189. */
  1190. UnicodeString& _format(Calendar& cal, UnicodeString& appendTo, FieldPositionHandler& handler, UErrorCode& status) const;
  1191. /**
  1192. * Called by format() to format a single field.
  1193. *
  1194. * @param appendTo Output parameter to receive result.
  1195. * Result is appended to existing contents.
  1196. * @param ch The format character we encountered in the pattern.
  1197. * @param count Number of characters in the current pattern symbol (e.g.,
  1198. * "yyyy" in the pattern would result in a call to this function
  1199. * with ch equal to 'y' and count equal to 4)
  1200. * @param capitalizationContext Capitalization context for this date format.
  1201. * @param fieldNum Zero-based numbering of current field within the overall format.
  1202. * @param handler Records information about field positions.
  1203. * @param cal Calendar to use
  1204. * @param status Receives a status code, which will be U_ZERO_ERROR if the operation
  1205. * succeeds.
  1206. */
  1207. void subFormat(UnicodeString &appendTo,
  1208. UChar ch,
  1209. int32_t count,
  1210. UDisplayContext capitalizationContext,
  1211. int32_t fieldNum,
  1212. FieldPositionHandler& handler,
  1213. Calendar& cal,
  1214. SimpleDateFormatMutableNFs &mutableNFs,
  1215. UErrorCode& status) const; // in case of illegal argument
  1216. /**
  1217. * Used by subFormat() to format a numeric value.
  1218. * Appends to toAppendTo a string representation of "value"
  1219. * having a number of digits between "minDigits" and
  1220. * "maxDigits". Uses the DateFormat's NumberFormat.
  1221. *
  1222. * @param currentNumberFormat
  1223. * @param appendTo Output parameter to receive result.
  1224. * Formatted number is appended to existing contents.
  1225. * @param value Value to format.
  1226. * @param minDigits Minimum number of digits the result should have
  1227. * @param maxDigits Maximum number of digits the result should have
  1228. */
  1229. void zeroPaddingNumber(NumberFormat *currentNumberFormat,
  1230. UnicodeString &appendTo,
  1231. int32_t value,
  1232. int32_t minDigits,
  1233. int32_t maxDigits) const;
  1234. /**
  1235. * Return true if the given format character, occuring count
  1236. * times, represents a numeric field.
  1237. */
  1238. static UBool isNumeric(UChar formatChar, int32_t count);
  1239. /**
  1240. * Returns TRUE if the patternOffset is at the start of a numeric field.
  1241. */
  1242. static UBool isAtNumericField(const UnicodeString &pattern, int32_t patternOffset);
  1243. /**
  1244. * Returns TRUE if the patternOffset is right after a non-numeric field.
  1245. */
  1246. static UBool isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset);
  1247. /**
  1248. * initializes fCalendar from parameters. Returns fCalendar as a convenience.
  1249. * @param adoptZone Zone to be adopted, or NULL for TimeZone::createDefault().
  1250. * @param locale Locale of the calendar
  1251. * @param status Error code
  1252. * @return the newly constructed fCalendar
  1253. */
  1254. Calendar *initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status);
  1255. /**
  1256. * Called by several of the constructors to load pattern data and formatting symbols
  1257. * out of a resource bundle and initialize the locale based on it.
  1258. * @param timeStyle The time style, as passed to DateFormat::createDateInstance().
  1259. * @param dateStyle The date style, as passed to DateFormat::createTimeInstance().
  1260. * @param locale The locale to load the patterns from.
  1261. * @param status Filled in with an error code if loading the data from the
  1262. * resources fails.
  1263. */
  1264. void construct(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);
  1265. /**
  1266. * Called by construct() and the various constructors to set up the SimpleDateFormat's
  1267. * Calendar and NumberFormat objects.
  1268. * @param locale The locale for which we want a Calendar and a NumberFormat.
  1269. * @param status Filled in with an error code if creating either subobject fails.
  1270. */
  1271. void initialize(const Locale& locale, UErrorCode& status);
  1272. /**
  1273. * Private code-size reduction function used by subParse.
  1274. * @param text the time text being parsed.
  1275. * @param start where to start parsing.
  1276. * @param field the date field being parsed.
  1277. * @param stringArray the string array to parsed.
  1278. * @param stringArrayCount the size of the array.
  1279. * @param monthPattern pointer to leap month pattern, or NULL if none.
  1280. * @param cal a Calendar set to the date and time to be formatted
  1281. * into a date/time string.
  1282. * @return the new start position if matching succeeded; a negative number
  1283. * indicating matching failure, otherwise.
  1284. */
  1285. int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
  1286. const UnicodeString* stringArray, int32_t stringArrayCount,
  1287. const UnicodeString* monthPattern, Calendar& cal) const;
  1288. /**
  1289. * Private code-size reduction function used by subParse.
  1290. * @param text the time text being parsed.
  1291. * @param start where to start parsing.
  1292. * @param field the date field being parsed.
  1293. * @param stringArray the string array to parsed.
  1294. * @param stringArrayCount the size of the array.
  1295. * @param cal a Calendar set to the date and time to be formatted
  1296. * into a date/time string.
  1297. * @return the new start position if matching succeeded; a negative number
  1298. * indicating matching failure, otherwise.
  1299. */
  1300. int32_t matchQuarterString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
  1301. const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;
  1302. /**
  1303. * Used by subParse() to match localized day period strings.
  1304. */
  1305. int32_t matchDayPeriodStrings(const UnicodeString& text, int32_t start,
  1306. const UnicodeString* stringArray, int32_t stringArrayCount,
  1307. int32_t &dayPeriod) const;
  1308. /**
  1309. * Private function used by subParse to match literal pattern text.
  1310. *
  1311. * @param pattern the pattern string
  1312. * @param patternOffset the starting offset into the pattern text. On
  1313. * outupt will be set the offset of the first non-literal character in the pattern
  1314. * @param text the text being parsed
  1315. * @param textOffset the starting offset into the text. On output
  1316. * will be set to the offset of the character after the match
  1317. * @param whitespaceLenient <code>TRUE</code> if whitespace parse is lenient, <code>FALSE</code> otherwise.
  1318. * @param partialMatchLenient <code>TRUE</code> if partial match parse is lenient, <code>FALSE</code> otherwise.
  1319. * @param oldLeniency <code>TRUE</code> if old leniency control is lenient, <code>FALSE</code> otherwise.
  1320. *
  1321. * @return <code>TRUE</code> if the literal text could be matched, <code>FALSE</code> otherwise.
  1322. */
  1323. static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOffset,
  1324. const UnicodeString &text, int32_t &textOffset,
  1325. UBool whitespaceLenient, UBool partialMatchLenient, UBool oldLeniency);
  1326. /**
  1327. * Private member function that converts the parsed date strings into
  1328. * timeFields. Returns -start (for ParsePosition) if failed.
  1329. * @param text the time text to be parsed.
  1330. * @param start where to start parsing.
  1331. * @param ch the pattern character for the date field text to be parsed.
  1332. * @param count the count of a pattern character.
  1333. * @param obeyCount if true then the count is strictly obeyed.
  1334. * @param allowNegative
  1335. * @param ambiguousYear If true then the two-digit year == the default start year.
  1336. * @param saveHebrewMonth Used to hang onto month until year is known.
  1337. * @param cal a Calendar set to the date and time to be formatted
  1338. * into a date/time string.
  1339. * @param patLoc
  1340. * @param numericLeapMonthFormatter If non-null, used to parse numeric leap months.
  1341. * @param tzTimeType the type of parsed time zone - standard, daylight or unknown (output).
  1342. * This parameter can be NULL if caller does not need the information.
  1343. * @return the new start position if matching succeeded; a negative number
  1344. * indicating matching failure, otherwise.
  1345. */
  1346. int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,
  1347. UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,
  1348. int32_t patLoc, MessageFormat * numericLeapMonthFormatter, UTimeZoneFormatTimeType *tzTimeType, SimpleDateFormatMutableNFs &mutableNFs,
  1349. int32_t *dayPeriod=NULL) const;
  1350. void parseInt(const UnicodeString& text,
  1351. Formattable& number,
  1352. ParsePosition& pos,
  1353. UBool allowNegative,
  1354. NumberFormat *fmt) const;
  1355. void parseInt(const UnicodeString& text,
  1356. Formattable& number,
  1357. int32_t maxDigits,
  1358. ParsePosition& pos,
  1359. UBool allowNegative,
  1360. NumberFormat *fmt) const;
  1361. int32_t checkIntSuffix(const UnicodeString& text, int32_t start,
  1362. int32_t patLoc, UBool isNegative) const;
  1363. /**
  1364. * Translate a pattern, mapping each character in the from string to the
  1365. * corresponding character in the to string. Return an error if the original
  1366. * pattern contains an unmapped character, or if a quote is unmatched.
  1367. * Quoted (single quotes only) material is not translated.
  1368. * @param originalPattern the original pattern.
  1369. * @param translatedPattern Output param to receive the translited pattern.
  1370. * @param from the characters to be translited from.
  1371. * @param to the characters to be translited to.
  1372. * @param status Receives a status code, which will be U_ZERO_ERROR
  1373. * if the operation succeeds.
  1374. */
  1375. static void translatePattern(const UnicodeString& originalPattern,
  1376. UnicodeString& translatedPattern,
  1377. const UnicodeString& from,
  1378. const UnicodeString& to,
  1379. UErrorCode& status);
  1380. /**
  1381. * Sets the starting date of the 100-year window that dates with 2-digit years
  1382. * are considered to fall within.
  1383. * @param startDate the start date
  1384. * @param status Receives a status code, which will be U_ZERO_ERROR
  1385. * if the operation succeeds.
  1386. */
  1387. void parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& status);
  1388. /**
  1389. * Return the length matched by the given affix, or -1 if none.
  1390. * Runs of white space in the affix, match runs of white space in
  1391. * the input.
  1392. * @param affix pattern string, taken as a literal
  1393. * @param input input text
  1394. * @param pos offset into input at which to begin matching
  1395. * @return length of input that matches, or -1 if match failure
  1396. */
  1397. int32_t compareSimpleAffix(const UnicodeString& affix,
  1398. const UnicodeString& input,
  1399. int32_t pos) const;
  1400. /**
  1401. * Skip over a run of zero or more Pattern_White_Space characters at
  1402. * pos in text.
  1403. */
  1404. int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const;
  1405. /**
  1406. * Skip over a run of zero or more isUWhiteSpace() characters at pos
  1407. * in text.
  1408. */
  1409. int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos) const;
  1410. /**
  1411. * Initialize NumberFormat instances used for numbering system overrides.
  1412. */
  1413. void initNumberFormatters(const Locale &locale,UErrorCode &status);
  1414. /**
  1415. * Parse the given override string and set up structures for number formats
  1416. */
  1417. void processOverrideString(const Locale &locale, const UnicodeString &str, int8_t type, UErrorCode &status);
  1418. /**
  1419. * Used to map pattern characters to Calendar field identifiers.
  1420. */
  1421. static const UCalendarDateFields fgPatternIndexToCalendarField[];
  1422. /**
  1423. * Map index into pattern character string to DateFormat field number
  1424. */
  1425. static const UDateFormatField fgPatternIndexToDateFormatField[];
  1426. /**
  1427. * Lazy TimeZoneFormat instantiation, semantically const
  1428. */
  1429. TimeZoneFormat *tzFormat() const;
  1430. const NumberFormat* getNumberFormatByIndex(UDateFormatField index) const;
  1431. /**
  1432. * Used to map Calendar field to field level.
  1433. * The larger the level, the smaller the field unit.
  1434. * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10,
  1435. * UCAL_MONTH level is 20.
  1436. */
  1437. static const int32_t fgCalendarFieldToLevel[];
  1438. /**
  1439. * Map calendar field letter into calendar field level.
  1440. */
  1441. static int32_t getLevelFromChar(UChar ch);
  1442. /**
  1443. * Tell if a character can be used to define a field in a format string.
  1444. */
  1445. static UBool isSyntaxChar(UChar ch);
  1446. /**
  1447. * The formatting pattern for this formatter.
  1448. */
  1449. UnicodeString fPattern;
  1450. /**
  1451. * The numbering system override for dates.
  1452. */
  1453. UnicodeString fDateOverride;
  1454. /**
  1455. * The numbering system override for times.
  1456. */
  1457. UnicodeString fTimeOverride;
  1458. /**
  1459. * The original locale used (for reloading symbols)
  1460. */
  1461. Locale fLocale;
  1462. /**
  1463. * A pointer to an object containing the strings to use in formatting (e.g.,
  1464. * month and day names, AM and PM strings, time zone names, etc.)
  1465. */
  1466. DateFormatSymbols* fSymbols; // Owned
  1467. /**
  1468. * The time zone formatter
  1469. */
  1470. TimeZoneFormat* fTimeZoneFormat;
  1471. /**
  1472. * If dates have ambiguous years, we map them into the century starting
  1473. * at defaultCenturyStart, which may be any date. If defaultCenturyStart is
  1474. * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system
  1475. * values are used. The instance values defaultCenturyStart and
  1476. * defaultCenturyStartYear are only used if explicitly set by the user
  1477. * through the API method parseAmbiguousDatesAsAfter().
  1478. */
  1479. UDate fDefaultCenturyStart;
  1480. UBool fHasMinute;
  1481. UBool fHasSecond;
  1482. /**
  1483. * Sets fHasMinutes and fHasSeconds.
  1484. */
  1485. void parsePattern();
  1486. /**
  1487. * See documentation for defaultCenturyStart.
  1488. */
  1489. /*transient*/ int32_t fDefaultCenturyStartYear;
  1490. struct NSOverride : public UMemory {
  1491. const SharedNumberFormat *snf;
  1492. int32_t hash;
  1493. NSOverride *next;
  1494. void free();
  1495. NSOverride() : snf(NULL), hash(0), next(NULL) {
  1496. }
  1497. ~NSOverride();
  1498. };
  1499. /**
  1500. * The number format in use for each date field. NULL means fall back
  1501. * to fNumberFormat in DateFormat.
  1502. */
  1503. const SharedNumberFormat **fSharedNumberFormatters;
  1504. UBool fHaveDefaultCentury;
  1505. BreakIterator* fCapitalizationBrkIter;
  1506. };
  1507. inline UDate
  1508. SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const
  1509. {
  1510. return fDefaultCenturyStart;
  1511. }
  1512. U_NAMESPACE_END
  1513. #endif /* #if !UCONFIG_NO_FORMATTING */
  1514. #endif // _SMPDTFMT
  1515. //eof