Date date = new Date (); SYSTEM.OUT.PRINTLN (date);
We will print out the Thu 18:05:49 CST format string in the console
The following code can be implemented to convert the time string in the CST format of Java into a Date object and the required datetime format!
String date = "Thu 18:05:49 CST 2015"; SimpleDateFormat SDF = new SimpleDateFormat ("EEE MMM dd HH:mm:ss zzz yyyy", locale.us);D ate d = sdf.parse (Date); String formatdate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"). Format (d); System.out.println (formatdate);
Get GMT time code in Java:
Calendar cd = Calendar.getinstance (); SimpleDateFormat SDF = new SimpleDateFormat ("EEE d MMM yyyy HH:mm:ss ' GMT '", locale.us); Sdf.settimezone ( Timezone.gettimezone ("gmt+8")); Set time zone to GMT +8 for Beijing time East eight zone string str = Sdf.format (Cd.gettime ()); System.out.println (str);
Itmyhome
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java formatted CST date time