Java code
java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
The various date representation letters in JAVA are as follows:
G |
Era symbol | Text | AD |
y |
year | Year | 1996 ; 96 |
M |
Month of the year | Month | July ; Jul ; 07 |
w |
Week of the year | Number | 27 |
W |
Week number of month | Number | 2 |
D |
Number of days in the year | Number | 189 |
d |
Days in month | Number | 10 |
F |
Day of the month | Number | 2 |
E |
Days of the week | Text | Tuesday ; Tue |
a |
Am/pm mark | Text | PM |
H |
The number of hours in a day (0-23) | Number | 0 |
k |
Number of hours in a day (1-24) | Number | 24 |
K |
Hours in am/pm (0-11) | Number | 0 |
h |
Hours in am/pm (1-12) | Number | 12 |
m |
Minutes in hour | Number | 30 |
s |
Seconds in minutes | Number | 55 |
S |
Milliseconds | Number | 978 |
z |
Time zone | General time zone | Pacific Standard Time ; PST ; GMT-08:00 |
Z |
Time zone | RFC 822 time zone | -0800 |
Reference article