Error problem of CST time format
Scene: For example, the date directly identified in the database is ' Tue June 18:13:54 CST 2017 ', the normal conversion result is ' 2017-06-14 08:13:54 ', the result is 14 hours to me the whole of the depressed not, originally on this CST, GMT this time is vague, so I went online to check the Great God's post, after the record.
After conversion as shown (with error):
Cause of the error: CST can be said that the United States, Australia, Cuba, China 4 different time zones, GMT for Greenwich Mean Time, due to China in the East 8 region, the United States in the West 6 region, East plus West reduction so total difference of 14 hours. Because the Java Date conversion takes the United States time, it causes a time error.
Workaround:
public static void Main (string[] args) throws ParseException {
String time = "Tue June 18:13:54 CST 2017";
SimpleDateFormat SDF = new SimpleDateFormat ("EEE MMM dd HH:mm:ss zzz", yyyy);
String formatdate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"). Format (Sdf.parse (time));
System.out.println (formatdate);
}
Final effect:
Note that it is best to use GMT time to learn suggestions for your convenience.