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






Suffix                  Replaced By

a                       Abbreviated weekday name

A                       Full weekday name

b                       Abbreviated month name

B                       Full month name

c                       Standard date and time string formatted as day month date hh::mm:ss tzone year

C                       First two digits of year

d                       Day of month as a decimal (01-31)

D                       month/day/year

e                       Day of month as a decimal (1-31)

F                       year-month-day

h                       Abbreviated month name

H                       Hour (00 to 23)

I                       Hour (01 to 12)

j                       Day of year as a decimal (001 to 366)

k                       Hour (0 to 23)

l                       Hour (1 to 12)

L                       Millisecond (000 to 999)

m                       Month as decimal (01 to 13)

M                       Minute as decimal (00 to 59)

N                       Nanosecond (000000000 to 999999999)

p                       Locale's equivalent of AM or PM in lowercase

Q                       Milliseconds from 1/1/1970

r                       hh:mm:ss (12-hour format)

R                       hh:mm (24-hour format)

S                       Seconds (00 to 60)

s                       Seconds from 1/1/1970 UTC

T                       hh:mm:ss (24-hour format)

y                       Year in decimal without century (00 to 99)

Y                       Year in decimal including century (0001 to 9999)

z                       Offset from UTC

Z                       Time 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