Friday, July 27, 2012

Using Multiple Date Formats in SpringMVC's InitBinder

The other day I found myself needing my SpringMVC controller to be able to map multiple formats to a date. I was using the CustomDateEditor to map the normal MM/dd/yyyy format, but then I found that I also needed to be able to accept the EEE MMM dd HH:mm:ss zzz yyyy format.

Not being able to find an existing solution, I decided to roll my own. Enjoy.

Below shows how it is used in the controller, the actual editor class, and then the test

No comments:

Post a Comment