Tag Archives: Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.Date’;

[How to Solve] Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.Date’;

Receive Date data in the background, use String type to receive, convert format when writing

String-“Date, first modify the format, and then use parse to convert to Date

      java.text.SimpleDateFormat ft = new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " ); 
        Date date =ft.parse(businessDate);

The transmission data format is the same as the foreground data

Date->String

Date date=ft.format(businessDate);

Encountered Unparseable date: “2021-08-08”

The data structure sent from the front end is different from the set structure, and an error is reported.