1 cst 转 时间格式
public class 时间转换 {
/**
* CSt 转换日期格式
* @param cstTime
* @return
*/
public static void main(String[] args) {
String time="Wed Jun 02 17:53:31 CST 2021";
try{
String time1 = cstTurnTime(time);
System.out.println(time1);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String cstTurnTime (String cstTime) throws Exception{
if(cstTime==null ){
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
Date date = (Date) sdf.parse(cstTime);
String formatStr2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
return formatStr2;
}
}