Code example for GregorianCalendar

Methods: add, clone

0
//        target.add(Calendar.WEEK_OF_YEAR, 13); 
//        checkShortParse("2001-5-30 +26 weeks",now,target); 
    } 
 
    public void testParseShortFutureDates2() throws Exception { 
        GregorianCalendar now = new GregorianCalendar(2004, Calendar.AUGUST, 1, 12, 0);
        checkShortParse("2004-8-1",now,now); // should always work
        GregorianCalendar target = (GregorianCalendar) now.clone();
        target.add(Calendar.DAY_OF_MONTH, 1);
        checkShortParse("2004-8-1 +1 day",now,target,true);
        try { 
            checkShortParse("2004-8-1 +1 day",now,target,false);
            fail("Expected AssertionFailedError");
        } catch (AssertionFailedError pe) {
            if (pe.getMessage().startsWith("Expected AssertionFailedError")) { // don't swallow our failure
                throw pe;
            } 
        } 
//        target.add(Calendar.WEEK_OF_YEAR, 1); 
//        checkShortParse("2004-8-1 +1 week",now,target); 
//        target.add(Calendar.WEEK_OF_YEAR, 12);