格式化Mon Dec 12 15:00:14 CST 2011日期

public static String getFormateDateStr(String str) {
        Date d = null;
        if(StringUtils.isEmpty(str)) {
            log.error("DateUtils|getFormateDateStr入参为空");
            return null;
        }
        
        SimpleDateFormat sdfSource = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        SimpleDateFormat sdfTarget = new SimpleDateFormat("yyyy.MM.dd", Locale.US);
        try {
            d = sdfSource.parse(str);
        } catch (ParseException e) {
            log.error("DateUtils|getFormateDateStr异常,入参为:"+str+",错误信息:"+e);
            return null;
        }
        return sdfTarget.format(d);
    }

你可能感兴趣的:(格式化Mon Dec 12 15:00:14 CST 2011日期)