Code example for GregorianCalendar

Methods: add, clone

0
        } catch (ParseException expected) {
        } 
    } 
 
    public void testParseDec31Lenient() throws Exception { 
        GregorianCalendar now = new GregorianCalendar(2007, Calendar.DECEMBER, 30, 12, 0);
        checkShortParse("2007-12-30",now,now); // should always work
        GregorianCalendar target = (GregorianCalendar) now.clone();
        target.add(Calendar.DAY_OF_YEAR, +1); // tomorrow
        checkShortParse("2007-12-31",now,target, true);
    } 
 
    public void testParseJan01Lenient() throws Exception { 
        GregorianCalendar now = new GregorianCalendar(2007, Calendar.DECEMBER, 31, 12, 0);
        checkShortParse("2007-12-31",now,now); // should always work
        GregorianCalendar target = (GregorianCalendar) now.clone();
        target.add(Calendar.DAY_OF_YEAR, +1); // tomorrow
        checkShortParse("2008-1-1",now,target, true);
    } 
 
    public void testParseJan01() throws Exception {