Interactive date formats cheat sheet

<b:dateTimePicker > is based on a JavaScript component using the moment.js library. Unfortunately, this library uses different format strings than Java's SimpleDateFormatter does. For the sake of backward compatibility, we've decided to stick with the moment.js format strings. To make your life easier, here's a little cheat sheet converting the date formats.

Hint:The language selector doesn't support AJAX. Plus, it seems to be a bit unreliable on this server.

Note that the internationalization doesn't work with the moment.js version of the interactive example. For some reason, the Nashorn JavaScript engine seems to ignore the locale setting of moment.js.

Note that the internationalization doesn't work with the moment.js version of the interactive example. For some reason, the Nashorn JavaScript engine seems to ignore the locale setting of moment.js.

KeyJava (example)moment.jsmoment.js (example)Description
'(not printed)[] escape character
aPMA AM or PM
D201DDD day in year - one to three digits
DD201 day in year- two or three digits
DDD201DDDD day in year- three digits
d20D day in month - one or two digits
dd20DD day in month - two digits
EDoddd day name in week - short
EEDoddd day name in week - short
EEEDoddd day name in week - short
EEEEDonnerstagdddd day name in week - full
F3 day of week in month
Gn. Chr. era - AD or BC
H14H hour - one or two digits, 24 hours, 0..23
HH14HH hour - two digits, 24 hours, 00..23
h2h hour - one or two digits, 12 hours, 1..12
hh02hh hour - two digits, 12 hours, 01..12
K2 hour - one or two digits, 12 hours, 0..11
KK02 hour - two digits, 12 hours, 00..11
k14k hour - one or two digits, 12 hours, 1..24
kk14kk hour - two digits, 24 hours, 01..24
M7M month in year - two digits, 1..12
MM07MM month in year - two digits, 01..12
MMMJulMMM month in year - short text
MMMMJuliMMMM month in year - full text
m25m minutes - one or two digits
mm25mm minutes - two digits
S358S millisecond
SS358SS millisecond
SSS358SSS millisecond
s26s seconds- one or two digits
ss26ss seconds - two digits
u4E day number of week - 1=Monday, 7=Sunday
W3 week in month - one or two digits
WW03 week in month - two digits, zero-padded
w29W week in year - one or two digits
ww29WW week in year - two digits, zero-padded
X+02 ISO 8601 time zone - - hours only
XX+0200ZZ ISO 8601 time zone - short
XXX+02:00Z ISO 8601 time zone - long
Y2017 week year - two digits
YY17gg week year - two digits
YYY2017 week year - three digits
YYYY2017gggg week year - all digits
y2017YYYY year - every digit
yy17YY year - two digits
yyy2017YYYY year - three digits
yyyy2017YYYY year - every digit
Z+0200ZZ RFC 822 time zone
zMESZ General time zone
zzMESZ General time zone
zzzMESZ General time zone
zzzzMitteleuropäische Sommerzeit General time zone
moment.jsmoment.js (example)JavaJava (example)Description
A a PMAM or PM
a am or pm
D d 20day in month - one or two digits
DD dd 20day in month - two digits
DDD D 201day in year
DDDD DDD 201day in year
Do day of month with ordinal
d day in week - 0=Sunday, 6=Saturda
ddd E Doday name - short
dddd EEEE Donnerstagday name - full
E u 4ISO day of week - 1..7
e Locale day of week - 0..6
H H 14hour - one or two digits, 24 hours, 0..23
HH HH 14hour - two digits, 24 hours, 00..23
h h 2hour - one or two digits, 12 hours, 1..12
hh hh 02hour - two or two digits, 12 hours, 01..12
k k 14hour - one or two digits, 24 hours, 1..24
kk kk 14hour - two digits, 24 hours, 01..24
M M 7month in year - two digits, 01..12
MM MM 07month in year - two digits, 01..12
MMM MMM Julmonth in year - short text
MMMM MMMM Julimonth in year - full text
m m 25minutes - one or two digits
mm mm 25minutes - two digits
Q quarter in year - 1..
S S 363fractional seconds - 0...99
SS SS 363fractional seconds - 00...99
SSS SSS 364fractional seconds - 000...99
s s 26seconds - one or two digits
ss ss 26second - two digits
W w 29week in year - one or two digits, 1..53
WW ww 29week in year - two digits, 01..53
w locale week in year - one or two digits, 1..53
ww locale week in year - two digits, 01..53
X UNIX timestamp
x UNIX timestamp - milliseconds
Y year - any number of digits and sig
YY yy 17year - two digits
YYYY yyyy 2017year - all digits
Z XXX +02:00offset from UTC
ZZ ZZ +0200offset from UTC
[ ' (not printed)escape character
] ' (not printed)escape character