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:
- Springboot uses the Datetimeformat (pattern = “yyyy MM DD HH: mm: SS”) annotation to automatically convert the string to date type error
- Get the time value from the database and report an error: Java sql. Timestamp cannot be cast to java. lang.Long
- [How to Solve] Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.Date’;
- MySQL from_ Unixtime() and UNIX_ The difference of timestamp() function
- Python SyntaxError: unexpected character after line continuation character
- [Solved] Error: org.springframework.validation.BeanPropertyBindingResult
- Using Vue + Axios: axios.post error: request failed with status code 400 is one of the solutions
- [Solved] mapper.xml Error: java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,
- [Solved] java.lang.IllegalArgumentException: Cannot format given Object as a Date
- C++ Error: passing ” “as” ” discards qualifiers