【发布时间】:2014-06-26 14:02:38
【问题描述】:
我正在尝试创建一个 LocalDate 对象:
LocalDate date = LocalDate.parse(
"1. juli 2014",
DateTimeFormatter.ofPattern("d. LLLL YYYY", new Locale("nb", "NO"));
但我得到一个例外:
java.time.format.DateTimeParseException: Text '1. juli 2014' could not be parsed:
Unable to obtain LocalDate from TemporalAccessor:
{WeekBasedYear[WeekFields[MONDAY,4]]=2014, MonthOfYear=7, DayOfMonth=1},
ISO of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1919)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1854)
at java.time.LocalDate.parse(LocalDate.java:400)
异常似乎表明那里有正确的数据(“juli”是挪威语,是第 7 个月)。
【问题讨论】:
-
@MarceloBezerra 不,那是 Joda 时间,不是 Java 8 时间
-
我想你可能在 jdk 8 中发现了一个 bug,恭喜你,stackoverflow.com/questions/22874374/…
-
@NimChimpsky 霍雷! :D