Created
July 17, 2012 15:21
-
-
Save bmchild/3130043 to your computer and use it in GitHub Desktop.
Useful Spring MVC InitBinders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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