- //日期输出格式
- String targetFormat = "yyyy-MM-dd HH:mm:ss";
- //日期原始格式
- String origFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSz";
- String s = "1988-11-06T12:14:05.671+08:00";
- //去掉时区部分的冒号
- s = s.replaceAll(":[^:]*$", "00");
- System.out.println(s);
- DateFormat format = new SimpleDateFormat(origFormat);
- Date date = format.parse(s);
- format = new SimpleDateFormat(targetFormat);
- String dateString = format.format(date);
- System.out.println(dateString);
转载:http://iamyida.iteye.com/blog/2207715
时间: 2024-10-30 06:32:03