import java.util.SimpleTimeZone; //导入方法依赖的package包/类
public void Test4278609() {
SimpleTimeZone tz = new SimpleTimeZone(0, "MyTimeZone",
/* DST start day: August, 1, 0:00 */
Calendar.AUGUST, 1, 0, 0,
/* DST end day: January, 1, 0:00 (wall-clock)*/
Calendar.JANUARY, 1, 0, 0,
60 * 60 * 1000);
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
// setting a date using GMT zone just after the end rule of tz zone
cal.clear();
cal.set(Calendar.ERA, GregorianCalendar.AD);
cal.set(1998, Calendar.DECEMBER, 31, 23, 01, 00);
Date date = cal.getTime();
int millis = cal.get(Calendar.HOUR_OF_DAY) * 3600000
+ cal.get(Calendar.MINUTE) * 60000
+ cal.get(Calendar.SECOND) * 1000
+ cal.get(Calendar.MILLISECOND);
/* we must use standard local time */
millis += tz.getRawOffset();
int offset = tz.getOffset(cal.get(Calendar.ERA),
cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH),
cal.get(Calendar.DATE),
cal.get(Calendar.DAY_OF_WEEK),
millis);
if (offset != 0) {
SimpleDateFormat format = new SimpleDateFormat("dd MMM HH:mm:ss zzz",
Locale.US);
format.setTimeZone(tz);
errln("Wrong DST transition: " + tz
+ "\na date just after DST = " + format.format(date)
+ "\ngetOffset = " + offset);
}
}