0, // midnight wall time
Calendar.FEBRUARY, -29, -Calendar.SUNDAY,// end: February, 29 or before, Sunday
0); // midnight wall time
// Gregorian calendar with the UTC time zone for getting sample test date/times.
GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("Etc/GMT"));
// "Unable to create the UTC calendar: %s"
int[] data = {
// UTC time (6 fields) followed by
// expected time zone offset in hours after GMT (negative=before GMT).
// int year, month, day, hour, minute, second, offsetHours
2006, Calendar.NOVEMBER, 5, 02, 59, 59, -3,
2006, Calendar.NOVEMBER, 5, 03, 00, 00, -2,
2007, Calendar.FEBRUARY, 25, 01, 59, 59, -2,
2007, Calendar.FEBRUARY, 25, 02, 00, 00, -3,
2007, Calendar.NOVEMBER, 4, 02, 59, 59, -3,
2007, Calendar.NOVEMBER, 4, 03, 00, 00, -2,
2008, Calendar.FEBRUARY, 24, 01, 59, 59, -2,
2008, Calendar.FEBRUARY, 24, 02, 00, 00, -3,
2008, Calendar.NOVEMBER, 2, 02, 59, 59, -3,
2008, Calendar.NOVEMBER, 2, 03, 00, 00, -2,
2009, Calendar.FEBRUARY, 22, 01, 59, 59, -2,
2009, Calendar.FEBRUARY, 22, 02, 00, 00, -3,
2009, Calendar.NOVEMBER, 1, 02, 59, 59, -3,
2009, Calendar.NOVEMBER, 1, 03, 00, 00, -2,
2010, Calendar.FEBRUARY, 28, 01, 59, 59, -2,
2010, Calendar.FEBRUARY, 28, 02, 00, 00, -3
};
TimeZone timezones[] = { tz1, tz2 };
TimeZone tz;
Date dt;
int t, i, raw, dst;
int[] offsets = new int[2]; // raw = offsets[0], dst = offsets[1]
for (t = 0; t < timezones.length; ++t) {
tz = timezones[t];
for (i = 0; i < data.length; i+=7) {
gc.set(data[i], data[i+1], data[i+2],
data[i+3], data[i+4], data[i+5]);
dt = gc.getTime();
tz.getOffset(dt.getTime(), false, offsets);
raw = offsets[0];
dst = offsets[1];
if ((raw + dst) != data[i+6] * MILLIS_PER_HOUR) {
errln("test case " + t + "." + (i/7) + ": " +