We have
- One server A running on Jboss EAP6/Windows/US
- Another server B running on Jboss EAP6/Linux/South America
Current spring application, has a UI page that pass a Date select box, when click submit, this date object will pass to the next page as a field of a java bean.
Now the situation is:
Server A runs this form fine without problem, but server B throw exception when submit:
nested exception is java.lang.IllegalArgumentException:
Unparseable string: [Unparseable date: "Wed May 29 16:34:58 ART 2013",
Unparseable date: "Wed May 29 16:34:58 ART 2013"]]
Seems server B doesn't know how to process the data format as Wed May 29 16:34:58 ART 2013
, even I add an @initBinder
@InitBinder
public void registerDateBinder(WebDataBinder binder) {
DateFormat printFormat = new SimpleDateFormat(DateTimeFormat.patternForStyle("S-", LocaleContextHolder.getLocale())); // format for joda time dojo UI
printFormat.setLenient(false);
DateFormat sortFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy" , LocaleContextHolder.getLocale()); // format for whatever return from form
sortFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new ExpandableCustomDateEditor(printFormat, Arrays.asList(printFormat, sortFormat), true));
}
ExpandableCustomDateEditor
is referred from this article
Interesting part is above issue happens when that Date object is a field of the bean
public String showSecondView(Form aForm,
Model uiModel) {
.....
}
But this works without problem in another controller without @InitBinder
public String list(Model uiModel,
@RequestParam(value = "fromDate", required = false) Date fromrDate,
.....)
....
}
But how come this error still happens, even with that @initBinder? I have made post before and seems platform has different way to translate timezone
code, but Spring, I think it is capable to support internationalization right?