无法将日期为2020年4月15日12:14:17 AM解析为LocalDatetime [英] Unable to parse date Apr 15, 2020 12:14:17 AM to LocalDatetime
本文介绍了无法将日期为2020年4月15日12:14:17 AM解析为LocalDatetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用
DateTimeFormatter.ofPattern("MMM DD',' YYYY h:mm:ss a")
我要例外
Exception in thread "main" java.time.format.DateTimeParseException: Text 'Apr 15, 2020 12:14:17 AM' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {MonthOfYear=4, WeekBasedYear[WeekFields[SUNDAY,1]]=2020, DayOfYear=15},ISO resolved to 00:14:17 of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
at com.paypal.Test.main(Test.java:76)
推荐答案
请尝试使用小写形式的日期和年份格式.
Try this format having lower case for date and year.
DateTimeFormatter.ofPattern("MMM dd',' yyyy hh:mm:ss a")
这篇关于无法将日期为2020年4月15日12:14:17 AM解析为LocalDatetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文