register date editor in yr controller:
@InitBinder protected void initBinder(WebDataBinder binder) { binder.registerCustomEditor(LocalDate.class, new LocalDateEditor()); }
and then the data editor itself might look like this:
public class LocalDateEditor extends PropertyEditorSupport{ @Override public void setAsText(String text) throws IllegalArgumentException{ setValue(Joda.getLocalDateFromddMMMyyyy(text)); } @Override public String getAsText() throws IllegalArgumentException { return Joda.getStringFromLocalDate((LocalDate) getValue()); } }
I use my own abstract utility class (Joda) for parsing dates, in fact LocalDates from the Joda Datetime library - it is recommended as standard java date / calendar - an abomination, IMHO. But you should get this idea. In addition, you can register a global editor, so you do not need to do this every controller (I do not remember how).
Nimchimpsky
source share