Code example for GregorianCalendar

Methods: add, clone

0
    } 
 
//    Lenient mode allows for dates up to 1 day in the future 
 
    public void testParseShortFutureDates1() throws Exception { 
        GregorianCalendar now = new GregorianCalendar(2001, Calendar.MAY, 30, 12, 0);
        checkShortParse("2001-5-30",now,now); // should always work
        GregorianCalendar target = (GregorianCalendar) now.clone();
        target.add(Calendar.DAY_OF_MONTH, 1);
        checkShortParse("2001-5-30 +1 day",now,target,true);
        try { 
            checkShortParse("2001-5-30 +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("2001-5-30 +1 week",now,target); 
//        target.add(Calendar.WEEK_OF_YEAR, 12); 
//        checkShortParse("2001-5-30 +13 weeks",now,target); 
//        target.add(Calendar.WEEK_OF_YEAR, 13); 
//        checkShortParse("2001-5-30 +26 weeks",now,target);