1
votes

I am setting date format using the following code :

@InitBinder
public void initBinder(final WebDataBinder binder) {
    binder.initDirectFieldAccess();

    final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}

and sending the date in the same format from the jsp but getting error as:

Failed To Convert Property Value Of Type [Java.Lang.String] To Required Type [Java.Util.Date] For Property BidDate; Nested Exception Is Java.Lang.IllegalArgumentException: Could Not Parse Date: Unparseable Date: "05/28/2017"

2

2 Answers

1
votes

Your date format is dd/MM/yyyy but you pass it an MM/dd/yyyy date (05/28/2017)

1
votes

From your JSP comes the date format different from the one specified in the class, it means your JSP send 05/28/2017 (MM/dd/yyyy) and your class is waiting for the format 28/05/2017 (dd/MM/yyyy).

So, you can try to change this:

final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

for this:

final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");

Or in turn you can change the date format in your JSP