Create a new DateFormatter using a custom pattern as described at
https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax. For examples
the pattern "yyyy.MM.dd G at HH:mm:ss zzz" produces “1996.07.10 AD at 15:08:56 PDT” in English for
the PDT time zone.
A date pattern is a string of characters, where specific strings of characters are replaced with date and
time data from a calendar when formatting or used to generate data for a calendar when parsing.
The Date Field Symbol Table
contains the characters used in patterns to show the appropriate formats
for a given locale, such as yyyy for the year. Characters may be used multiple times. For example, if y is
used for the year, "yy" might produce “99”, whereas "yyyy" produces “1999”. For most numerical fields, the
number of characters specifies the field width. For example, if h is the hour, "h" might produce “5”, but
"hh" produces “05”. For some characters, the count specifies whether an abbreviated or full form should be
used, but may have other choices, as given below.
Two single quotes represents a literal single quote, either inside or outside single quotes. Text within
single quotes is not interpreted in any way (except for two adjacent single quotes). Otherwise all ASCII
letter from a to z and A to Z are reserved as syntax characters, and require quoting if they are to represent
literal characters. In addition, certain ASCII punctuation characters may become variable in the future (eg
: being interpreted as the time separator and / as a date separator, and replaced by respective locale-sensitive
characters in display).
“Stand-alone” values refer to those designed to stand on their own independently, as opposed to being with
other formatted values. “2nd quarter” would use the wide stand-alone format "qqqq", whereas “2nd quarter 2007”
would use the regular format "QQQQ yyyy". For more information about format and stand-alone forms, see
CLDR Calendar Elements.
The pattern characters used in the Date Field Symbol Table are defined by CLDR; for more information see
CLDR Date Field Symbol Table.
👉 Note that the examples may not reflect current CLDR data.