Date curdate = new Date ();
String datestr = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss SSS", Locale.china). Format (curdate);
Various dates in Java represent the following letters:
An alphabetic date or time element represents an example
G |
Era Marker |
Text |
AD |
Y |
Years |
Year |
1996; 96 |
M |
Months of the year |
Month |
July; June June; 07 |
W |
Number of weeks in the year |
Number |
27 |
W |
Number of weeks in the month |
Number |
2 |
D |
Days in the year |
Number |
189 |
D |
Days in the month |
Number |
10 |
F |
Weeks in the month |
Number |
2 |
E |
Days in the week |
Text |
Tuesday; Tue |
A |
AM/PM Mark |
Text |
Pm |
H |
Number of hours in a day (0-23) |
Number |
0 |
K |
Number of hours in a day (1-24) |
Number |
24 |
K |
Number of hours in am/pm (0-11) |
Number |
0 |
H |
Number of hours in am/pm (1-12) |
Number |
12 |
M |
Number of minutes in the hour |
Number |
30 |
S |
Number of seconds in minutes |
Number |
55 |
S |
Number of milliseconds |
Number |
978 |
Z |
Time |
General Time Zone |
Pacific Standard time; PST; gmt-08:00 |
Z |
Time |
RFC 822 Time Zone |
-0800 |