Code example for GregorianCalendar

Methods: setTime

0
        assertEquals(60 * 60 * 1000, normal.getTime() - dst.getTime());
    } 
 
    public void testDstZoneNameWithNonDstTimestamp() throws Exception { 
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz");
        Calendar calendar = new GregorianCalendar(AMERICA_LOS_ANGELES);
        calendar.setTime(format.parse("2011-06-21T10:00 Pacific Standard Time")); // 18:00 GMT-8
        assertEquals(11, calendar.get(Calendar.HOUR_OF_DAY)); // 18:00 GMT-7
        assertEquals(0, calendar.get(Calendar.MINUTE));
    } 
 
    public void testNonDstZoneNameWithDstTimestamp() throws Exception { 
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz");
        Calendar calendar = new GregorianCalendar(AMERICA_LOS_ANGELES);
        calendar.setTime(format.parse("2010-12-21T10:00 Pacific Daylight Time")); // 17:00 GMT-7
        assertEquals(9, calendar.get(Calendar.HOUR_OF_DAY)); // 17:00 GMT-8
        assertEquals(0, calendar.get(Calendar.MINUTE));
    } 
 
    // http://b/4723412 
    public void testDstZoneWithNonDstTimestampForNonHourDstZone() throws Exception {