//(旧)格式化时间,Jdk7:
//将时间字符串转化为标准时间格式
String accessTime = "20181212162923";
if (accessTime != null && accessTime.trim().length() != 0) {
Date time = new Date();
//2018-09-09 19:15:14
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
try {
time = sdf.parse(accessTime);
} catch (ParseException e) {
}
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
accessTime = sdf2.format(time);
System.out.println(accessTime);
}
//输出:2018-12-12T16:29:23+08:00
//(新)JDK1.8将字符串转换为标准的ISO-8601的时间格式:
//(新)将字符串转换为标准的ISO-8601的时间格式
String timestamp = "20181212162923";
try {
DateTimeFormatter formatter = Dat