Java uses simpleDateFormat to format the date and time
Java uses simpleDateFormat to format the date and time. First, let's take a look at all the representation of the formatting log: time and date identifier: yyyy: MM: dd: hh: 1 ~ 12-hour (1-12) HH: 24-hour (0-23) mm: minute ss: S: millisecond E: day of the week D: day of the year F: the week of March (the total number of days of the month will be divided by 7) w: the week of the year W: The day of the month (calculated based on the actual situation) a: The last afternoon logo k: is similar to HH, indicating a 24-hour system (1-24) a day ). K: similar to hh <span style = "font-family: Arial, Helvetica, sans-serif;"> </span> <span style = "font-family: Arial, helvetica, sans-serif; ">, indicates 12 hours a day (0-11 ). </Span> z: the time zone must be case sensitive. Otherwise, the formatted date will be different. You can write multiple letters at the same time, for example, yyyyyyyyy. Based on the size of your number and the length of the written letter, fill in the front with zero. For example, if you want to format the time from 2013-08-13 15:29:44 to on January 1, the case in the time identifier of the formatted date is incorrect. The following is the most complete example of the date format: SimpleDateFormat sdf = new SimpleDateFormat ("yyyyyy-MM-dd HH (hh): mm: ss s e d f w a k K z "); long times = System. currentTimeMillis (); System. out. println (times); Date date = new Date (times); String tim = sdf. format (date); System. out. println (tim); output result: 00002013-08-14 15 (03): 56: 40 742 Wednesday 226 2 33 3 pm 15 3 CST --------------------------------------------------------------------- ----------- SimpleDateFormat sdf = new SimpleDateFormat ("It is yyyy-MM-dd HH (hh) mm minute ss second S millisecond week E the day of this year the day of this month the day of this year ~ 24 System time K0-11 hour System time z time zone "); long times = System. currentTimeMillis (); System. out. println (times); Date date = new Date (times); String tim = sdf. format (date); System. out. println (tim); output result: August 14, 2013 16 (04), 03 seconds, 812 milliseconds, Wednesday, 226th days of this year, 2nd weeks of this month, 33rd weeks of this year, 3rd weeks of this month, 161 ~ Time in 24 format: 40-11 hour format: CST Time Zone