Code example for SimpleDateFormat

Methods: format, parse

0
 
    public void testString() throws Exception { 
        MVELCalendarCoercion co = new MVELCalendarCoercion();
        assertTrue(co.canConvertFrom( Calendar.class ));
 
        SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
 
        String dt = df.format(df.parse("10-Jul-1974"));
 
        Date dt_ = DateUtils.parseDate( dt );
        Calendar cal = Calendar.getInstance();
        cal.setTime( dt_ );
        assertEquals(cal, co.convertFrom( dt ));
    } 
 
}