/**
* Test date locale conversions.
*/
public void testDateConverter()
{
DateConverter converter = new DateConverter();
assertNull(new DateConverter().convertToObject("", Locale.US));
Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
cal.clear();
cal.set(2002, Calendar.OCTOBER, 24);
Date date = cal.getTime();
assertEquals("24-10-02", converter.convertToString(date, DUTCH_LOCALE));
assertEquals(date, converter.convertToObject("24-10-02", DUTCH_LOCALE));
assertEquals("10/24/02", converter.convertToString(date, Locale.US));
assertEquals(date, converter.convertToObject("10/24/02", Locale.US));
try
{
converter.convertToObject("whatever", Locale.US);
fail("Conversion should have thrown an exception");
}
catch (ConversionException e)
{
// this is correct
}
try
{
converter.convertToObject("10/24/02whatever", Locale.US);
fail("Conversion should have thrown an exception");
}
catch (ConversionException e)
{
// this is correct