【发布时间】:2021-06-01 04:55:36
【问题描述】:
我是 java 新手,我不明白我的日期解析出了什么问题。我已经尝试了许多类似帖子的解决方案,阅读了 DateTimeFormatter 文档,但仍然卡住了。任何帮助表示赞赏。谢谢。
代码
String date = "2021-02-19T00:45:09.798Z"
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSZ");
ZonedDateTime parsedDate = ZonedDateTime.parse(date, formatter);
错误
java.time.format.DateTimeParseException: Text '2021-02-19T00:45:09.798Z' could not be parsed, unparsed text found at index 23
我也尝试过使用DateTimeFormatter.ofPattern(pattern).withZone(zone) 并收到同样的错误。
【问题讨论】: