public static void main(String[] args) throws ParseException {
String dt="Thu May 28 18:23:17 CST 2015";
SimpleDateFormat sdf1= new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf2.format(sdf1.parse(dt)));
String s = "Tue Jul 12 12:10:11 GMT+08:00 2016";
SimpleDateFormat sf1 = new SimpleDateFormat("EEE MMM dd hh:mm:ss z yyyy", Locale.ENGLISH);
Date date = sf1.parse(s);
SimpleDateFormat sf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sf2.format(date);
System.out.println(str);
}
输出结果:
2015-05-28 18:23:17
2016-07-12 00:10:11