为什么这段代码给我一个例外?
String myFormat = "dd MMMMM uuuu";
String dateToFormat = "26 Mai 2010";
DateTimeFormatter myFormatter = new DateTimeFormatterBuilder().appendPattern(myFormat)
.toFormatter().withResolverStyle(ResolverStyle.STRICT);
LocalDate myDate=LocalDate.parse(dateToFormat,myFormatter);
例外:
java.time.format.DateTimeParseException: Text '26 Mai 2010' could not be parsed at index 4
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.LocalDate.parse(LocalDate.java:400)
如果我尝试使用 'MMMM' 而不是 'MMMMM' ,它会按预期工作。
String myFormat = "dd MMMM uuuu";
米脂
相关分类