Code example for GregorianCalendar

Methods: addset

0
        cal.setTimeZone(tz);
        assertEquals(25200000, cal.get(Calendar.ZONE_OFFSET));
    } 
 
    public void testAddOneDayOverDstForwardAdds23HoursAt0100() { 
        Calendar calendar = new GregorianCalendar(AMERICA_SAO_PAULO);
        calendar.set(2011, 9, 15, 1, 0); // 01:00 GMT-3
        double hoursSinceEpoch = hoursSinceEpoch(calendar);
        calendar.add(Calendar.DATE, 1);
        assertEquals(23.0, hoursSinceEpoch(calendar) - hoursSinceEpoch);
        assertCalendarEquals(calendar, 2011, 9, 16, 1, 0); // 01:00 GMT-2; +23 hours
    } 
 
    /** 
     * At their daylight savings time switch, Sao Paulo changes from 
     * "00:00 GMT-3" to "01:00 GMT-2". When adding time across this boundary, 
     * drop an hour to keep the hour+minute constant unless that prevents the 
     * date field from being incremented. 
     * http://code.google.com/p/android/issues/detail?id=17502 
     */ 
Stop searching for code, let great code find you!  Add Codota to your java IDE