Formatting Time and Date: The Time and Date Format Suffixes : Formatting Date Time « Development « Java Tutorial






SuffixReplaced By
aAbbreviated weekday name
AFull weekday name
bAbbreviated month name
BFull month name
cStandard date and time string formatted as day month date hh::mm:ss tzone year
CFirst two digits of year
dDay of month as a decimal (01 to 31)
Dmonth/day/year
eDay of month as a decimal (1 to 31)
Fyear-month-day
hAbbreviated month name
HHour (00 to 23)
IHour (01 to 12)
jDay of year as a decimal (001 to 366)
kHour (0 to 23)
lHour (1 to 12)
LMillisecond (000 to 999)
mMonth as decimal (01 to 13)
MMinute as decimal (00 to 59)
NNanosecond (000000000 to 999999999)
PLocale's equivalent of AM or PM in uppercase
pLocale's equivalent of AM or PM in lowercase
QMilliseconds from 1/1/1970
rhh:mm (12-hour format)
Rhh:mm (24-hour format)
SSeconds (00 to 60)
sSeconds from 1/1/1970 UTC
Thh:mm:ss (24-hour format)
yYear in decimal without century (00 to 99)
YYear in decimal including century (0001 to 9999)
zOffset from UTC
ZTime zone name










6.9.Formatting Date Time
6.9.1.Formatting Time and Date: The Time and Date Format Suffixes
6.9.2.%tr: Formatting time and date
6.9.3.%tc: Display complete time and date information
6.9.4.%tl:%tM: Display just hour and minute
6.9.5.%tB %tb %tm: Display month by name and number
6.9.6.Display 12-hour time format
6.9.7.Display 24-hour time format.
6.9.8.Display short date format.
6.9.9.Display date using full names.
6.9.10.Display complete time and date information: using %T rather than %t.
6.9.11.Display hour and minute, and include AM or PM indicator.
6.9.12.The Time and Date Format Suffixes
6.9.13.Display several time and date formats