jdk/test/sun/util/calendar/zi/Zoneinfo.java
changeset 40677 8243adf9888e
parent 23349 30ea1ad58166
--- a/jdk/test/sun/util/calendar/zi/Zoneinfo.java	Tue Aug 30 09:36:23 2016 +0800
+++ b/jdk/test/sun/util/calendar/zi/Zoneinfo.java	Tue Aug 30 14:16:16 2016 +0900
@@ -373,6 +373,7 @@
         tz.getOffsetIndex(zrec.getGmtOffset());
 
         int lastGmtOffsetValue = -1;
+        ZoneRec prevzrec = null;
         int currentSave = 0;
         boolean usedZone;
         for (int zindex = 0; zindex < zone.size(); zindex++) {
@@ -441,6 +442,15 @@
                                                                      currentSave);
                             if (zrec.hasUntil()) {
                                 if (transition >= zrec.getUntilTime(currentSave)) {
+                                    // If the GMT offset changed from the previous one,
+                                    // record fromTime as a transition.
+                                    if (!fromTimeUsed && prevzrec != null
+                                        && gmtOffset != prevzrec.getGmtOffset()) {
+                                        tz.addTransition(fromTime,
+                                                         tz.getOffsetIndex(gmtOffset+currentSave),
+                                                         tz.getDstOffsetIndex(currentSave));
+                                        fromTimeUsed = true; // for consistency
+                                    }
                                     break year_loop;
                                 }
                             }
@@ -452,8 +462,6 @@
                                     if (fromTime != minTime) {
                                         int prevsave;
 
-                                        ZoneRec prevzrec = zone.get(zindex - 1);
-
                                         // See if until time in the previous
                                         // ZoneRec is the same thing as the
                                         // local time in the next rule.
@@ -555,6 +563,7 @@
                 fromYear = zrec.getUntilYear();
                 year = zrec.getUntilYear();
             }
+            prevzrec = zrec;
         }
 
         if (tz.getDSTType() == Timezone.UNDEF_DST) {