Java Reference
In-Depth Information
Day of month: 199
e
Naturally, the valid range for day of month, month of year, and so forth,
depends on the calendar that is being used. To continue the example,
the following code will print the current date in the common mm/dd/yy
format:
System.out.printf("%1$tm/%1$td/%1$ty %n", new Date());
As you can see, all the information about a date or time can be extracted
and you can combine the pieces in whatever way you need. Doing so,
however, is rather tedious both for the writer and any subsequent read-
ers of the code. To ease the tedium a third set of conversion suffixes
provides convenient shorthands for common combinations of the other
conversions:
Time in 24-hour clock hh:mm format ( "%tH:%tM" )
R
Time in 24-hour clock hh:mm:ss format ( "%tH:%tM:%tS" )
T
Time in 12-hour clock h:mm:ss am/pm format ( "%tI:%tM:%tS
%Tp" )
r
Date in mm/dd/yy format ( "%tm/%td/%ty" )
D
Complete date in ISO 8601 format ( "%tY-%tm-%TD" )
F
 
Search WWH ::




Custom Search