错误类型:java.time.format.DateTimeParseException: Text '20201217' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2020-12-17 of type java.time.format.Parsed
String time = "20201217";
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDateTime date = LocalDateTime.parse(time, dateFormat);
代码中,定义的time为yyyyMMdd, 在DateTimeFormatter时的格式是yyyyMMdd,这类错误是LocalDateTime类要求必须有yyyyMMddHHmmss格式,把LocalDateTime换为LocalDate,错误解决
总结: LocalDateTime其实是 LocalDate + LocalTime 两部分都得有,不然会报错