Reference url:http://www.busfly.net/csdn/post/java_string_fomat_date_time_simpledateformat.html
Key code:
Java code
Java.text.SimpleDateFormat sdf=New java.text.SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss SSS");
The various dates in Java represent the following letters:
Alphabetical date or time element represents an example
G |
Era Marker |
Text |
AD |
y |
Years |
Year |
1996 ;96 |
M |
Month of the Year |
Month |
July ; Jul ;07 |
w |
Number of weeks in the year |
Number |
27 |
W |
Number of weeks in the month |
Number |
2 |
D |
Number of days in the year |
Number |
189 |
d |
Number of days in month |
Number |
10 |
F |
Week of the Month |
Number |
2 |
E |
Days of the Week |
Text |
Tuesday ;Tue |
a |
AM/PM Mark |
Text |
PM |
H |
Number of hours in the day (0-23) |
Number |
0 |
k |
Number of hours in the 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 hours |
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 |
Java date format milliseconds representation method