Java将CST的时间字符串转换成需要的日期格式字符串
Thu Jul 30 11:56:02 CST 2020转换成2020-07-30 11:56:02
String dateStr = "Wed Sep 16 11:26:23 CST 2009";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
//java.util.Date对象
Date date = (Date) sdf.parse(dateStr);
//2009-09-16
String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
System.out.println(formatStr);
//2009-09-16 11:26:23
String formatStr2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
System.out.println(formatStr2);