我希望能够解析像月(1-12)和年份组成的日期,例如:
1.2015
12.2015
转换为LocalDate
使用以下代码时,我遇到了一个异常:
final DateTimeFormatter monthYearFormatter = DateTimeFormatter.ofPattern("M.yyyy");
LocalDate monthYearDate = LocalDate.parse(topPerformanceDate, monthYearFormatter);
< p > < em > java.time.format.DateTimeParseException:无法解析文本“6.2015”:无法从TemporalAccessor获取LocalDate:{MonthOfYear = 6,Year = 2015},类型为java.time.format.Parsed
< p > 对于短月份格式,文档对我不太清楚。
< p > 编辑: 我猜问题是缺少月份的天数?