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
D269DDD day in year - one to three digits
DD269 day in year- two or three digits
DDD269DDDD day in year- three digits
d26D day in month - one or two digits
dd26DD day in month - two digits
EDiddd day name in week - short
EEDiddd day name in week - short
EEEDiddd day name in week - short
EEEEDienstagdddd day name in week - full
F4 day of week in month
Gn. Chr. era - AD or BC
H16H hour - one or two digits, 24 hours, 0..23
HH16HH hour - two digits, 24 hours, 00..23
h4h hour - one or two digits, 12 hours, 1..12
hh04hh hour - two digits, 12 hours, 01..12
K4 hour - one or two digits, 12 hours, 0..11
KK04 hour - two digits, 12 hours, 00..11
k16k hour - one or two digits, 12 hours, 1..24
kk16kk hour - two digits, 24 hours, 01..24
M9M month in year - two digits, 1..12
MM09MM month in year - two digits, 01..12
MMMSepMMM month in year - short text
MMMMSeptemberMMMM month in year - full text
m19m minutes - one or two digits
mm19mm minutes - two digits
S923S millisecond
SS923SS millisecond
SSS923SSS millisecond
s36s seconds- one or two digits
ss36ss seconds - two digits
u2E day number of week - 1=Monday, 7=Sunday
W4 week in month - one or two digits
WW04 week in month - two digits, zero-padded
w39W week in year - one or two digits
ww39WW 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 26day in month - one or two digits
DD dd 26day in month - two digits
DDD D 269day in year
DDDD DDD 269day in year
Do day of month with ordinal
d day in week - 0=Sunday, 6=Saturda
ddd E Diday name - short
dddd EEEE Dienstagday name - full
E u 2ISO day of week - 1..7
e Locale day of week - 0..6
H H 16hour - one or two digits, 24 hours, 0..23
HH HH 16hour - two digits, 24 hours, 00..23
h h 4hour - one or two digits, 12 hours, 1..12
hh hh 04hour - two or two digits, 12 hours, 01..12
k k 16hour - one or two digits, 24 hours, 1..24
kk kk 16hour - two digits, 24 hours, 01..24
M M 9month in year - two digits, 01..12
MM MM 09month in year - two digits, 01..12
MMM MMM Sepmonth in year - short text
MMMM MMMM Septembermonth in year - full text
m m 19minutes - one or two digits
mm mm 19minutes - two digits
Q quarter in year - 1..
S S 926fractional seconds - 0...99
SS SS 926fractional seconds - 00...99
SSS SSS 926fractional seconds - 000...99
s s 36seconds - one or two digits
ss ss 36second - two digits
W w 39week in year - one or two digits, 1..53
WW ww 39week 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