Java Reference
In-Depth Information
Table 13-7. List of Suffix Characters for Time Formatting
Conversion Suffix
Description
'H'
A two-digit hour of the day for the 24-hour clock. The valid values are 00 to 23. 00 is used
for midnight.
'I'
A two-digit hour of the day for the 12-hour clock. The valid values are 01 to 12.
The 01 value corresponds to one o'clock in the morning or afternoon.
'k'
It behaves the same as the 'H' suffix except that it does not add a leading zero to the output.
Valid values are 0 to 23.
'l'
It behaves the same as 'I' suffix except that it does not add a leading zero. Valid values
are 1 to 12.
'M'
A two-digit minute within an hour. Valid values are 00 to 59.
'S'
A two-digit second within a minute. Valid values are 00 to 60. The value 60 is a special value
that is required to support leap seconds.
'L'
A three-digit millisecond within a second. Valid values are 000 to 999.
'N'
A nine-digit nanosecond within a second. The valid values are 000000000 to 999999999. The
precision of the nanosecond value is dependent on the precision that is supported by the
operating system.
'p'
It outputs a locale-specific morning or afternoon marker in lowercase. For example, for US
locale, it will output “am” or “pm”. If you want the output in uppercase (e.g., “AM” and “PM”
for US locale), you need to use the uppercase variant 'T' as the conversion character..
'z'
It outputs the numeric time zone offset from GMT (e.g., +0530).
'Z'
It is a string abbreviation of the time zone (e.g., CST, EST, IST, etc).
's'
It outputs seconds since the beginning of the epoch starting at January 1, 1970 midnight UTC.
'Q'
It outputs milliseconds since the beginning of the epoch starting at January 1, 1970
midnight UTC.
Table 13-8. List of Suffix Characters for Date Formatting
Conversion Suffix
Description
'B'
Locale-specific full name of the month, such as “January”, “February”, etc. for US locale.
'b'
Locale-specific abbreviated month name, such as “Jan”, “Feb”, etc. for US locale.
'h'
Same as 'b'
'A'
Locale-specific full name of the day of the week, such as “Sunday”, “Monday”, etc. for US locale.
'a'
Locale-specific short name of the day of the week, such as “Sun”, “Mon”, etc. for US locale.
'C'
It divides the four-digit year by 100 and formats the result as two digits. It adds a leading zero if
the resulting number is one digit. It ignores the fraction part from the result of the division by
100. Valid values are 00 to 99. For example, if the four-digit year is 2011, it will output 20; if the
four-digit year is 12, it will output 00.
( continued )
Search WWH ::




Custom Search