1、将EEE MMM dd HH:mm:ss zzz yyyy格式的数据转换成yyyy-MM-dd HH:mm:ss
- 代码如下
public static void main(String[] args) throws ParseException {
String dateStr = "Mon Oct 26 15:19:15 CST 2020";
DateFormat cstFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat gmtFormate = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
Date dateTime = gmtFormate.parse(dateStr);
String dateString = cstFormate.format(dateTime);
System.out.println(dateString);
}
- 转换结果如下