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

Add a method to Java controller to solve the problem

    /**
     * Solution: Failed to convert value of type 'java.lang.String' to required type 'java.util;
     * The main reason for this error is that the required type in the Controller class is Date, but the type passed on the page side is String, which eventually leads to this error.
     */
    @InitBinder
    public void initBinder(WebDataBinder binder, WebRequest request) {
        //convert the date Note that the conversion here should always be in the same format as the string passed in, e.g. 2015-9-9 should be yyyy-MM-dd
        DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor is a custom date editor
    }


Read More: