当前位置 博文首页 > zhang_sheng_nian的博客:前端传后台的时间格式(如:2019-05-01

    zhang_sheng_nian的博客:前端传后台的时间格式(如:2019-05-01

    作者:[db:作者] 时间:2021-06-19 19:53

    public class DateUtils1 {
        public static String dealDateFormat(String oldDate) {
            Date date1 = null;
            DateFormat df2 = null;
            try {
                oldDate= oldDate.replace("Z", " UTC");
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
                Date date = df.parse(oldDate);
                SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
                date1 = df1.parse(date.toString());
                df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            } catch (ParseException e) {
    
                e.printStackTrace();
            }
            return df2.format(date1);
        }
    
    }

    ?