JAVA Error: Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date

Java reports an error failed to convert property value of type ‘Java. Lang. string’ to required type ‘Java. Util. Date
the reason is that the string is transmitted from the front end to the background, and the date date type of Java class property needs the @datetimeformat annotation at this time, but pay attention to usage:
① if the date transmitted from the front end is year, month and day, the annotation is used as follows

/**
* birthday
*/
@ datetimeformat (pattern = “yyyy MM DD”)
private date ebirthday

② if the front-end message is year, month, day, hour, minute and second, it is used as follows in the annotation

/**
* birthday
*/
@ datetimeformat (pattern = “yyyy MM DD HH: mm: SS”)
private date ebirthday

OK! Problem solved! No, give me a private letter
those who feel helpful can pay attention to a wave! Often share programming experience!

Similar Posts: