@InitBinder private void initBinder(WebDataBinder webDataBinder) { webDataBinder.addCustomFormatter( new Formatter<Preferences>() { @Override public Preferences parse(String s, Locale locale) throws ParseException { String[] split = s.split("-"); Preferences preferences = new Preferences(); preferences.setTooltip(split[0]); preferences.setLanguage(split[1]); return preferences; } @Override public String print(Preferences preferences, Locale locale) { return null; } }); }
@InitBinder("dateWithCustomFormatter") public void initBinderUsingCustomFormatter(WebDataBinder binder) { binder.addCustomFormatter(new DateFormatter("yyyy-MM-dd")); }