LocalDate格式化问题

LocalDate.parse("2019-5-10",DateTimeFormatter.ofPattern("yyyy-MM-dd"))

运行报错:

Exception in thread "main" java.time.format.DateTimeParseException: Text '2019-5-1' could not be parsed at index 5

修正为:

LocalDate.parse("2019-5-10",DateTimeFormatter.ofPattern("yyyy-M-d"));
LocalDate.parse("2019-05-10",DateTimeFormatter.ofPattern("yyyy-M-d"));

即,使用DateTimeFormatter.ofPattern("yyyy-M-d")来格式化.

你可能感兴趣的:(问题总结)