2023-05-24 16:39:43.677 WARN 23684 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String "2023-05-24 00:00:00": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2023-05-24 00:00:00' could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDateTime` from String "2023-05-24 00:00:00": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2023-05-24 00:00:00' could not be parsed at index 10<EOL> at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 12, column: 22] (through reference chain: cc.wellcloud.cloud.dam3.model.entity.PlanEntity["backupBeginTime"])]
时间: 2024-01-21 20:17:10 浏览: 162
slf4j-api-1.7.28.jar
这个错误信息是由于在反序列化JSON字符串时,无法将字符串“2023-05-24 00:00:00”转换为LocalDateTime类型。DateTimeParseException 表示时间解析异常,它指示日期时间格式不符合ISO-8601格式。你可以检查一下传递给反序列化方法的日期时间格式是否正确。如果日期时间格式正确,那么你可以尝试使用指定的格式来反序列化日期时间字符串。例如,如果日期时间字符串的格式为“yyyy-MM-dd HH:mm:ss”,你可以使用以下代码将其转换为 LocalDateTime 类型:
```java
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse("2023-05-24 00:00:00", formatter);
```
这样就可以将字符串转换为 LocalDateTime 类型了。
阅读全文