- Override the initBinder method.
- Create a SimpleDateFormat, e.g. MM/dd/yyyy HH:mm:ss where M is month, d is day, y is year, H is hour(0-23), m is minute, and s is second.
- Set the date format lenient false, which means inputs do not have to match the format exactly
- Create a CustomDateEditor(dateFormat, true), where true means empty allowed.
- Register the editor to Date.class.
Thursday, April 24, 2008
Spring Framework - Date Field in a SimpleFormController
Subscribe to:
Post Comments (Atom)
1 comment:
this can be the code.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
dateFormat, false));
Post a Comment