1 Public Static voidMain (string[] args)throwsParseException {2SimpleDateFormat ceshifmt0=NewSimpleDateFormat ("gyyyy mm month dd Day hh mm min ss sec");3SimpleDateFormat ceshifmt1=NewSimpleDateFormat ("Yyyy/mm/dd hh:mm");4SimpleDateFormat ceshifmt2=NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");5SimpleDateFormat ceshifmt3=NewSimpleDateFormat ("yyyy mm month DD day hh" mm min ss sec E ");6SimpleDateFormat ceshifmt4=NewSimpleDateFormat ("Yyyy/mm/dd E");7SimpleDateFormat ceshifmt5=NewSimpleDateFormat (8"D Day of the year, W Week, one-month, W-week, K-time Z time zone");9Date now=NewDate ();Ten System.out.println (Ceshifmt0.format (now)); One System.out.println (Ceshifmt1.format (now)); A System.out.println (Ceshifmt2.format (now)); - System.out.println (Ceshifmt3.format (now)); - System.out.println (Ceshifmt4.format (now)); the System.out.println (Ceshifmt5.format (now)); -}
The result is:
July 27, 2010 A.D. 09:19 29 seconds
2010/07/27 09:19
2010-07-27 09:19:29
July 27, 2010 09:19 29 sec Tuesday
2010/07/27 Tuesday
No. 208 Day of the year, 31 weeks, one months, 5 weeks, 9 o'clock CST time zone
Impledateformat Date-time format mode parameter:
Alphabetical date or time element represents an example
G Era marker Text AD
Y year 1996; 96
The month in M year July; Jul; 07
Weeks in W year number 27
Weeks in W month number 2
Days in D year number 189
Days in the D month Number 10
Week number 2 in the F month
<span style= "Background-color: #ffcc00;" >e days of the week Text Tuesday; Tue (when I was deploying in native Oracle is the return week is Tuesday, and on the Oracle server is the return Tue.)
</span>a AM/PM Flag Text pm
H hours in the day (0-23) number 0
K Hours in the day (1-24) Number 24
Hours in K am/pm (0-11) number 0
Hours in H am/pm (1-12) Number 12
Minutes in M-hour number 30
Seconds in S minutes number 55
S MS Number 978
Z TimeZone general time zone Pacific PST; gmt-08:00
Z timezone RFC 822 time zone-0800
[Java] SimpleDateFormat