Error reporting about using LocalDateTime type to receive parameters

Error reporting about using LocalDateTime type to receive parameters

required parameters

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDateTime startDateTime

Passed parameters: 2023-03-30

报错:
Failed to convert property value of type ‘java.lang.String’ to required type ‘java.time.LocalDateTime’ for property…

Finally, it is found that if LocalDateTime is used to receive, the year, month, day, hour, minute, and second are required.
For example: 2023-03-30 15:29:00

If you only pass the year, month and day, you need to use LocalDate

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate

Then there is no problem!

Guess you like

Origin blog.csdn.net/weixin_42947972/article/details/129859041