From 78a74d61710baee7eff010557cad4029ae4b308e Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Fri, 9 Aug 2013 16:32:00 +0000 Subject: [PATCH] ICU-10281 Fixed a VTIMEZONE writer problem that may produce overlapping rules. X-SVN-Rev: 34025 --- .../core/src/com/ibm/icu/util/VTimeZone.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java index 0467650e70..c6e9035933 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/VTimeZone.java @@ -1424,8 +1424,15 @@ public class VTimeZone extends BasicTimeZone { // Not equivalent rule - write out two different rules writeZonePropsByDOW(w, true, dstName, dstFromOffset, dstToOffset, dstMonth, dstWeekInMonth, dstDayOfWeek, dstStartTime, dstUntilTime); - writeFinalRule(w, true, finalDstRule, - dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, dstStartTime); + + Date nextStart = finalDstRule.getNextStart(dstUntilTime, + dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, false); + + assert nextStart != null; + if (nextStart != null) { + writeFinalRule(w, true, finalDstRule, + dstFromOffset - dstFromDSTSavings, dstFromDSTSavings, nextStart.getTime()); + } } } } @@ -1447,13 +1454,21 @@ public class VTimeZone extends BasicTimeZone { // Use a single rule if possible if (isEquivalentDateRule(stdMonth, stdWeekInMonth, stdDayOfWeek, finalStdRule.getRule())) { writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset, - stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, MAX_TIME); + stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, MAX_TIME); } else { // Not equivalent rule - write out two different rules writeZonePropsByDOW(w, false, stdName, stdFromOffset, stdToOffset, stdMonth, stdWeekInMonth, stdDayOfWeek, stdStartTime, stdUntilTime); - writeFinalRule(w, false, finalStdRule, - stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, stdStartTime); + + Date nextStart = finalStdRule.getNextStart(stdUntilTime, + stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, false); + + assert nextStart != null; + if (nextStart != null) { + writeFinalRule(w, false, finalStdRule, + stdFromOffset - stdFromDSTSavings, stdFromDSTSavings, nextStart.getTime()); + + } } } }