// This bug actually occurs on Windows NT as well, and doesn't
// require the host zone to be set; it can be set in Java.
String[] ids = TimeZone.getAvailableIDs();
boolean bad = false;
for (int i=0; i<ids.length; ++i) {
TimeZone zone = TimeZone.getTimeZone(ids[i]);
GregorianCalendar cal = new GregorianCalendar(zone);
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
if (cal.get(Calendar.HOUR) != 5) {
logln("Fail: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
cal.clear();
cal.set(1900, 15, 5, 5, 8, 13);
logln("ms = " + cal.getTime() + " (" + cal.getTime().getTime() + ")");
cal.get(Calendar.HOUR);
java.util.GregorianCalendar cal2 = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone(ids[i]));
cal2.clear();
cal2.set(1900, 15, 5, 5, 8, 13);
cal2.get(Calendar.HOUR);
logln("java.util.GC: " + zone.getID() + " " +
zone.useDaylightTime() + "; DST_OFFSET = " +
cal2.get(Calendar.DST_OFFSET) / (60*60*1000.0) + "; ZONE_OFFSET = " +
cal2.get(Calendar.ZONE_OFFSET) / (60*60*1000.0) + "; getRawOffset() = " +
zone.getRawOffset() / (60*60*1000.0) +
"; HOUR = " + cal.get(Calendar.HOUR));
logln("ms = " + cal2.getTime() + " (" + cal2.getTime().getTime() + ")");
bad = true;
} else if (false) { // Change to true to debug
logln("OK: " + zone.getID() + " " +
zone.useDaylightTime() + " " +
cal.get(Calendar.DST_OFFSET) / (60*60*1000) + " " +
zone.getRawOffset() / (60*60*1000) +
": HOUR = " + cal.get(Calendar.HOUR));
}
}
if (bad) errln("TimeZone problems with GC");
}