DateConverter extends ConverterSupport { @Override protected Object convertToObject(final String text) throws Exception { for (DateFormat format : formats) { try { return format.parse(text); } catch (ParseException e) { } } return complexParse(text); } DateConverter();   }
@Test public void testToObjectImpl() throws Exception { Date expected = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1954"); Date actual = (Date) new DateConverter().convertToObject("locale=en_US format=MEDIUM Mar 1, 1954"); assertEquals(expected, actual); }
@Test public void testFallbackFormats() throws Exception { DateConverter converter = new DateConverter(); converter.convertToObject("2007-10-31"); converter.convertToObject("2007-10-31T19:19:19PDT"); }