String time = "11 12 21:29:01 +0800 2018";
ZonedDateTime c = ZonedDateTime.parse(time, DateTimeFormatter.ofPattern("MM dd HH:mm:ss xx yyyy"));
System.out.println(c);
String time2 = "Nov 12 21:29:01 +0800 2018";
ZonedDateTime b = ZonedDateTime.parse(time2, DateTimeFormatter.ofPattern("MMM dd HH:mm:ss xx yyyy"));
System.out.println(b);
第一个输出为:2018-11-12T21:29:01+08:00
第二个直接抛了异常:Exception in thread "main" java.time.format.DateTimeParseException: Text 'Nov 12 21:29:01 +0800 2018' could not be parsed at index 0
1
wdlth 2018-11-12 22:53:00 +08:00
|
2
OscarUsingChen 2018-11-12 23:44:11 +08:00
Locale 的问题?
|
3
twirain OP 用 eclipse 编的,提示 unknown source,参数也都勾上了,不知道什么问题
|