【发布时间】:2017-09-29 16:10:38
【问题描述】:
LocalDateTime.parse("2017-02-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
打印错误:
java.time.format.DateTimeParseException: Text '2017-02-02 08:59:12' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {MinuteOfHour=59, NanoOfSecond=0, SecondOfMinute=12, MicroOfSecond=0, MilliOfSecond=0, HourOfAmPm=8},ISO resolved to 2017-02-02 of type java.time.format.Parsed
Accoeding 消息看起来所有值都解析正确,但无论如何我看到了错误。
如何让它工作?
【问题讨论】:
-
LocalDate或LocalDateTime?您在格式化程序中指明小时等 -
我工作得很好!
-
异常表示你尝试解析为
LocalDateTime。您在问题中的代码有效 -
抱歉,各位,已更正
-
错误消息中要注意的详细信息是
HourOfAmPm=8。它没有说一天中的小时......
标签: java datetime datetime-format localdate