java.time.LocalDateTime cannot be cast to java.time.LocalDate
时间: 2023-10-28 08:00:15 浏览: 272
This error occurs when you try to cast an object of type `LocalDateTime` to `LocalDate`, which is not allowed because they are different types in the `java.time` package.
To fix this issue, you can use the `toLocalDate()` method of `LocalDateTime` to convert it to a `LocalDate` object. Here's an example:
```java
LocalDateTime dateTime = LocalDateTime.now();
LocalDate date = dateTime.toLocalDate();
```
Now, you have successfully converted the `LocalDateTime` object to a `LocalDate` object.
阅读全文