Code example for GregorianCalendar

Methods: add, clone

0
        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 { 
        GregorianCalendar now = new GregorianCalendar(2007, Calendar.JANUARY, 1, 12, 0);
        checkShortParse("2007-01-01",now,now); // should always work
        GregorianCalendar target = new GregorianCalendar(2006, Calendar.DECEMBER, 31, 12, 0);
        checkShortParse("2006-12-31",now,target, true);
        checkShortParse("2006-12-31",now,target, false);
    } 
 
}