The Time and Date Format Suffixes : Formatter « Development Class « Java






The Time and Date Format Suffixes

  

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 

   
    
  








Related examples in the same category

1.Formatter: format(String format, Object... args)
2.Formatter: %g
3.Formatting time and date
4.Demonstrate the %n and %% format specifiers
5.Demonstrate a field-width specifier
6.Create a table of squares and cubes
7.Demonstrate the precision modifier
8.Demonstrate left justification
9.Demonstrate the space format specifiers
10.Limit the number of decimal digits by specifying the precision
11.Using group separators.
12.Show positive values with a leading + and negative values within parentheses.
13.Use Formatter to vertically align numeric values.
14.Use Formatter to left-justify strings within a table.
15.Display several time and date formats
16.using the %t specifier with Formatter.
17.Display 12-hour time format
18.Display 24-hour time format.
19.Display short date format.
20.Display date using full names.
21.Display complete time and date information: using %T rather than %t.
22.Display hour and minute, and include AM or PM indicator.
23.locale-specific formatting.
24.Write formatted output directly to the console and to a file.
25.Formatter.ioException()
26.new Formatter(new OutputStream("test.fmt"))
27.Use arguments indexes to simplify the creation of a custom time and date format
28.Apply a mask to String