Pattern to Format Date and Time - Stefanius67/XFPDF GitHub Wiki
A date pattern is a string of characters, where specific strings of characters are replaced with date and time of the given value.
The Table below 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, h
for the hour 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.
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. Two single quotes represents a literal single quote, either inside or outside single quotes.
NOTE
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).
Pattern | Meaning | en_US | de_DE |
---|---|---|---|
Date | |||
y or yyyy |
year | 2022 | 2022 |
yy |
22 | 22 | |
QQQQ |
quarter | 2nd quarter | 2. Quartal |
Q |
2 | 2 | |
QQ |
02 | 02 | |
QQQ |
Q2 | Q2 | |
M |
month | 3 | 3 |
MM |
03 | 03 | |
MMM |
Oct. | Okt. | |
MMMM |
October | Oktober | |
MMMMM |
O | O | |
d |
day in month | 7 | 7 |
dd |
07 | 07 | |
e |
day of week | 3 (1=Sun) | 2 (1=Mon) |
E EE or EEE |
Wed | Mi. | |
EEEE |
Wednesday | Mittwoch | |
EEEEE |
W | M | |
EEEEEE |
We | Mi. | |
D |
day of year | 9 | 9 |
DD |
09 | 09 | |
DDD |
009 | 009 | |
w |
week of year | 5 | 5 |
ww |
05 | 05 | |
Time | |||
H |
hour in day (0~23) | 7 | 7 |
HH |
07 | 07 | |
K |
hour in am/pm (0~11) | 7 | 7 |
KK |
07 | 07 | |
m |
minute in hour | 7 | 7 |
mm |
07 | 07 | |
s |
second in minute | 7 | 7 |
ss |
07 | 07 |
For timezone formating ( z, Z, O, v, V, x, X
) see https://unicode-org.github.io