/**
* Set behavior of DST_OFFSET field. ICU4J Jitterbug 9.
*/
public void TestJ9() {
int HOURS = 60*60*1000;
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("PST"),
Locale.US);
final int END_FIELDS = 0x1234;
int[] DATA = {
// With no explicit ZONE/DST expect 12:00 am
Calendar.MONTH, Calendar.JUNE,
END_FIELDS,
0, 0, // expected hour, min
// Normal ZONE/DST for June 1 Pacific is 8:00/1:00
Calendar.MONTH, Calendar.JUNE,
Calendar.ZONE_OFFSET, -8*HOURS,
Calendar.DST_OFFSET, HOURS,
END_FIELDS,
0, 0, // expected hour, min
// With ZONE/DST of 8:00/0:30 expect time of 12:30 am
Calendar.MONTH, Calendar.JUNE,
Calendar.ZONE_OFFSET, -8*HOURS,
Calendar.DST_OFFSET, HOURS/2,
END_FIELDS,
0, 30, // expected hour, min
// With ZONE/DST of 8:00/UNSET expect time of 1:00 am
Calendar.MONTH, Calendar.JUNE,
Calendar.ZONE_OFFSET, -8*HOURS,
END_FIELDS,
1, 0, // expected hour, min
// With ZONE/DST of UNSET/0:30 expect 4:30 pm (day before)
Calendar.MONTH, Calendar.JUNE,
Calendar.DST_OFFSET, HOURS/2,
END_FIELDS,
16, 30, // expected hour, min
};
for (int i=0; i<DATA.length; ) {
int start = i;
cal.clear();
// Set fields
while (DATA[i] != END_FIELDS) {
cal.set(DATA[i++], DATA[i++]);
}
++i; // skip over END_FIELDS
// Get hour/minute
int h = cal.get(Calendar.HOUR_OF_DAY);
int m = cal.get(Calendar.MINUTE);
// Check
if (h != DATA[i] || m != DATA[i+1]) {
errln("Fail: expected " + DATA[i] + ":" + DATA[i+1] +
", got " + h + ":" + m + " after:");