格林威治时间转换
类型为 "Wed Oct 21 14:16:35 +0800 2020"; 对应掩码为 "EEE MMM dd HH:mm:ss Z yyyy";
21/Oct/2020:14:16:35 +0800 类似这个格式的
// 线程不安全
Date format = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z"
, new Locale("ENGLISH", "CHINA"))
.parse("21/Oct/2020:14:16:35 +0800");;
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(format));
// 线程安全
long millis1 = DateTimeFormat.forPattern("dd/MMM/yyyy:HH:mm:ss Z")
.withLocale(new Locale("ENGLISH", "CHINA"))
.parseDateTime("21/Oct/2020:14:16:35 +0800").getMillis();
System.out.println(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").print(millis1));
2020-05-29T16:05:39+08:00 类似这个格式的
// 线程不安全
Date format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
.parse("2020-05-29T16:05:39+08:00");
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(format1));
// 线程安全
long millis2 = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ")
.parseDateTime("2020-05-29T16:05:39+08:00").getMillis();
System.out.println(DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").print(millis2));
参考:
https://blog.csdn.net/qq_16618813/article/details/51446235
https://blog.csdn.net/kangbin825/article/details/72564531
https://blog.csdn.net/csdn_ds/article/details/72984646