Java 8在这里.我有以下代码:
final String createdDateStr = "20110920";
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYYMMdd");
final LocalDate localDate = LocalDate.parse(createdDateStr, formatter);
Run Code Online (Sandbox Code Playgroud)
在运行时,我得到以下异常:
java.time.format.DateTimeParseException: Text '20110920' could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.
Run Code Online (Sandbox Code Playgroud)
......被LocalDate.parse(...)调用抛出 解析器出了什么问题?!