我試圖創建一個對象LOCALDATE:如何使用「d。LLLL YYYY」模式從日期字符串中創建java.time.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)
的例外似乎表明,正確的數據就在那裏(「巨力」是挪威人並且是月號7)。
可能重複[喬達時間:如何將字符串轉換爲LocalDate?](http://stackoverflow.com/questions/2721614/joda-time-how-to-convert-string-to-localdate) –
@MarceloBezerra不,這是喬達的時間,而不是Java 8時間 – neu242
我想你可能已經在jdk 8中發現了一個bug,恭喜,http://stackoverflow.com/questions/22874374/what-is-the-motivation-for-two-不同的一週爲基礎的年定義在jsr - 310 – NimChimpsky