2018-05-01T00:00:00.000+08:00转2018-05-01 00:00:00

/**
     * 2018-05-01T00:00:00.000+08:00转2018-05-01 00:00:00
     * @param oldDateStr
     * @return
     * @throws ParseException
     */
    public static String dealDateFormat(String oldDateStr) throws ParseException {
        if(oldDateStr.length()<=10){
             return oldDateStr+" 23:59:59";
        }
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        Date  date = df.parse(oldDateStr);
        SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
        Date date1 =  df1.parse(date.toString());
        DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df2.format(date1);
    }


    public static void main(String[] args) throws ParseException {
        System.out.println(dealDateFormat("2018-05-01"));
        
    }

 

转载于:https://www.cnblogs.com/SimonHu1993/p/9139534.html

你可能感兴趣的:(2018-05-01T00:00:00.000+08:00转2018-05-01 00:00:00)