I am trying to register custom date editor in spring's MVC WebDataBinder to make spring parse my custom date fomat (to be exact, it's ISO format). I succeded with that by implementing CustomWebBindingInitializer.
public static class CustomWebBindingInitializer implements WebBindingInitializer {
@Override
public void initBinder(WebDataBinder webDataBinder, WebRequest webRequest) {
CustomDateEditor dateEditor = new CustomDateEditor(new ISODateFormat(), true);
webDataBinder.registerCustomEditor(Date.class, dateEditor);
}
}
Spring is using my editor and parses date successfully , but nontheless date field doesn't get bound and I get following error for the request:
"org.springframework.validation.BindException",,"defaultMessage":"Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'from'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: \"2016-08-01T10:35:04.126Z\""
What's worth noting: when I use default spring's format MM/DD/YYYY with my custom editor I get the same error, which means that spring is using my editor instead of default one.
when I use default spring's parser with format MM/DD/YYYY everything works and date gets bound, which is obvious of course.
Anyone had the same issue ?