Joda-Time版本
2.10.1
TimeZone.getDefault()的结果
sun.util.calendar.ZoneInfo [id =“ Europe / Belgrade”,offset = 3600000,dstSavings = 3600000,useDaylight = true,transitions = 119,lastRule = java.util.SimpleTimeZone [id = Europe / Belgrade,offset = 3600000,dstSavings = 3600000,useDaylight = true,startYear = 0,startMode = 2,startMonth = 2,startDay = -1,startDayOfWeek = 1,startTime = 3600000,startTimeMode = 2,endMode = 2,endMonth = 9,endDay = -1,endDayOfWeek = 1,endTime = 3600000,endTimeMode = 2]]
DateTimeZone.getDefault()的结果
UTC
问题描述
为PrecalculatedZone选择的偏移量不正确。 iTransitions包含错误的值(针对以下测试用例)
iTransitions = {long[3]@751}
0 = -9223372036854775808
1 = 947030400000 (2000-01-05T00:00:00.000Z)
2 = 947196000000 (2000-01-06T22:00:00.000Z)
<-22:00而不是00:00
originalDateTimeZone是UTC。
public void testPrecalculatedZoneOffsets() throws IOException {
DateTime minimumDate = new DateTime(1, 1, 1, 0, 0, 0, originalDateTimeZone);
DateTime firstDate = new DateTime(2000, 1, 5, 0, 0, 0, originalDateTimeZone);
DateTime secondDate = firstDate.plusDays(2);
int OFFSET = 120 * MILLIS_PER_MINUTE;
DateTimeZoneBuilder builder = new DateTimeZoneBuilder()
.setStandardOffset(0)
.addRecurringSavings("Offset initializing DST rule " + minimumDate.toString(), 0,
minimumDate.getYear(), minimumDate.getYear(), 'w', 1, 1, 0, false, minimumDate.getMillisOfDay())
.addCutover(firstDate.getYear(), 'w', firstDate.getMonthOfYear(), firstDate.getDayOfMonth(), 0, false, firstDate.getMillisOfDay())
.setStandardOffset(OFFSET)
.addRecurringSavings("Offset initializing DST rule " + firstDate.toString(),
0, firstDate.getYear(),
firstDate.getYear(), 'w', firstDate.getMonthOfYear(),
firstDate.getDayOfMonth(), 0, false, 0)
.addCutover(secondDate.getYear(), 'w', secondDate.getMonthOfYear(), secondDate.getDayOfMonth(), 0, false, secondDate.getMillisOfDay())
.setStandardOffset(0)
.addRecurringSavings("Offset initializing DST rule " + secondDate.toString(),
0, secondDate.getYear(),
secondDate.getYear(), 'w', secondDate.getMonthOfYear(),
secondDate.getDayOfMonth(), 0, false, 0);
DateTimeZone dateTimeZone = builder.toDateTimeZone("ID", false);
//Failing assertion
assertEquals(OFFSET, dateTimeZone.getOffset(secondDate.minusMinutes(1)));
assertEquals(OFFSET, dateTimeZone.getOffset(secondDate.minusDays(1)));
assertEquals(0, dateTimeZone.getOffset(secondDate.plusDays(1)));}
测试用例或iTransitions计算是否有问题?