[ Back | Previous | Next ]

Time Format Syntax.

Package:
java.text.*
Product:
JDK
Release:
1.1.x
Related Links:
DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat
Comment:
Time Format Syntax

To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:

SymbolMeaningPresentationExample
Gera designator (Text) AD
yyear (Number) 1996
Mmonth in year (Text & Number) July & 07
dday in month (Number) 10
hhour in am/pm (1~12) (Number) 12
Hhour in day (0~23) (Number) 0
mminute in hour (Number) 30
ssecond in minute(Number) 55
Smillisecond (Number) 978
Eday in week (Text) Tuesday
Dday in year (Number) 189
Fday of week in month (Number) 2 (2nd Wed in July)
wweek in year (Number) 27
Wweek in month (Number) 2
aam/pm marker (Text) PM
khour in day (1~24) (Number) 24
Khour in am/pm (0~11) (Number) 0
ztime zone (Text) Pacific Standard Time
'escape for text
''single quote '
Format Pattern Result
"yyyy.MM.dd G 'at' hh:mm:ss z"1996.07.10 AD at 15:08:56 PDT
"EEE, MMM d, ''yy" Wed, July 10, '96
"h:mm a" 12:08 PM
"hh 'o''''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" 0:00 PM, PST
"yyyyy.MMMMM.dd GGG hh:mm aaa"1996.July.10 AD 12:08 PM

1