2016-08-15T16:00:00.000Z 格式转换成yyyy-MM-dd HH:mm:ss格式

public static String UTCStringtODefaultString(String UTCString) {
    try
    {
        if (CommonUtils.notNullAndEmpty(UTCString)) {
            UTCString = UTCString.replace("Z", " UTC");
            SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
            SimpleDateFormat defaultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = utcFormat.parse(UTCString);
            return defaultFormat.format(date);
        }else{
            return null;
        }

    } catch(ParseException pe)
    {
        pe.printStackTrace();
        return null;
    }
}

  

posted on 2019-04-12 10:37  kkw105  阅读(2005)  评论(0编辑  收藏  举报