ImportOrg.springframework.context.ApplicationContext;ImportOrg.springframework.context.support.ClassPathXmlApplicationContext;ImportJava.text.SimpleDateFormat;ImportJava.util.Calendar; Public classTest2 { Public Static voidMain (string[] args) {ApplicationContext context=NewClasspathxmlapplicationcontext (Newstring[]{"Dispatcher-servlet.xml" }); Calendar Calendar= Context.getbean ("Calendar", Calendar.class); SimpleDateFormat format=NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); System.out.println (Format.format (Calendar.gettime ())); }}
YYYY: Year MM: DD: Day hh:1~12 Hour System (1-12) hh:24 Hour (0-23) mm: Min ss: sec S: milliseconds E: Days of the week D: The day of the year F: The first few weeks of January (the number of days total this month divided by 7) W: The Week of the year W: The Week of January (according to the actual situation) A: Last Afternoon logo K: Similar to HH, indicating a 24-hour day (1-24). K: Similar to HH, indicating a 12-hour day (0-11).
Tried, the week used the tail plus E (not lowercase), HH, MM, DD, MM, SS and C # syntax, just C # in the week is dddd, and can use FFFF to format the number of milliseconds, and Java does not support the format of milliseconds.
New SimpleDateFormat ("yyyy-m-d h:m:s E");
Go [Java] Date formatting