Skip to content

Instantly share code, notes, and snippets.

@bmchild
Created July 17, 2012 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmchild/3130043 to your computer and use it in GitHub Desktop.
Save bmchild/3130043 to your computer and use it in GitHub Desktop.
Useful Spring MVC InitBinders
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
// bind empty strings as null
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment