Skip to content

Tokens

Tokens are useful for formatting and parsing.

You can use the following tokens:

Standalone tokenFormat tokenDescriptionExample
Smillisecond, no padding54
SSSmillisecond, padded to 3054
ufractional seconds, functionally identical to SSS054
ssecond, no padding4
sssecond, padded to 2 padding04
mminute, no padding7
mmminute, padded to 207
hhour in 12-hour time, no padding1
hhhour in 12-hour time, padded to 201
Hhour in 24-hour time, no padding9
HHhour in 24-hour time, padded to 213
Znarrow offset+5
ZZshort offset+05:00
ZZZtechie offset+0500
ZZZZabbreviated named offsetEST
ZZZZZunabbreviated named offsetEastern Standard Time
zIANA zoneAmerica/New_York
ameridiemAM
dday of the month, no padding6
ddday of the month, padded to 206
cEday of the week, as number from 1-7 (Monday is 1, Sunday is 7)3
cccEEEday of the week, as an abbreviate localized stringWed
ccccEEEEday of the week, as an unabbreviated localized stringWednesday
cccccEEEEEday of the week, as a single localized letterW
LMmonth as an unpadded number8
LLMMmonth as an padded number08
LLLMMMmonth as an abbreviated localized stringAug
LLLLMMMMmonth as an unabbreviated localized stringAugust
LLLLLMMMMMmonth as a single localized letterA
yyear, unpadded2014
yytwo-digit year14
yyyyfour- to six- digit year, pads to 42014
Gabbreviated localized eraAD
GGunabbreviated localized eraAnno Domini
GGGGGone-letter localized eraA
kkISO week year, unpadded17
kkkkISO week year, padded to 42014
WISO week number, unpadded32
WWISO week number, padded to 232
oordinal (day of year), unpadded218
oooordinal (day of year), padded to 3218
Dlocalized numeric date9/4/2017
DDlocalized date with abbreviated monthAug 6, 2014
DDDlocalized date with full monthAugust 6, 2014
DDDDlocalized date with full month and weekdayWednesday, August 6, 2014
tlocalized time9:07 AM
ttlocalized time with seconds1:07:04 PM
tttlocalized time with seconds and abbreviated offset1:07:04 PM EDT
ttttlocalized time with seconds and full offset1:07:04 PM Eastern Daylight Time
Tlocalized 24-hour time13:07
TTlocalized 24-hour time with seconds13:07:04
TTTlocalized 24-hour time with seconds and abbreviated offset13:07:04 EDT
TTTTlocalized 24-hour time with seconds and full offset13:07:04 Eastern Daylight Time
fshort localized date and time8/6/2014, 1:07 PM
ffless short localized date and timeAug 6, 2014, 1:07 PM
fffverbose localized date and timeAugust 6, 2014, 1:07 PM EDT
ffffextra verbose localized date and timeWednesday, August 6, 2014, 1:07 PM Eastern Daylight Time
Fshort localized date and time with seconds8/6/2014, 1:07:04 PM
FFless short localized date and time with secondsAug 6, 2014, 1:07:04 PM
FFFverbose localized date and time with secondsAugust 6, 2014, 1:07:04 PM EDT
FFFFextra verbose localized date and time with secondsWednesday, August 6, 2014, 1:07:04 PM Eastern Daylight Time
qquarter, no padding9
qqquarter, padded to 213

Full list of tokens can be found here

Released under the MIT License.