< prev index next >

src/java.base/share/classes/sun/util/calendar/ZoneInfo.java

Print this page
rev 55814 : imported patch 8212970

@@ -271,11 +271,11 @@
             }
             return offset;
         }
 
         // beyond the transitions, delegate to SimpleTimeZone if there
-        // is a rule; otherwise, return rawOffset.
+        // is a rule; otherwise, return the offset of the last transition.
         SimpleTimeZone tz = getLastRule();
         if (tz != null) {
             int rawoffset = tz.getRawOffset();
             long msec = date;
             if (type != UTC_TIME) {

@@ -291,18 +291,23 @@
             if (offsets != null) {
                 offsets[0] = rawoffset;
                 offsets[1] = dstoffset;
             }
             return rawoffset + dstoffset;
-        }
-        int offset = getLastRawOffset();
+        } else {
+            // use the last transition
+            long val = transitions[transitions.length - 1];
+            int offset = this.offsets[(int)(val & OFFSET_MASK)] + rawOffsetDiff;
         if (offsets != null) {
-            offsets[0] = offset;
-            offsets[1] = 0;
+                int dst = (int)((val >>> DST_NSHIFT) & 0xfL);
+                int save = (dst == 0) ? 0 : this.offsets[dst];
+                offsets[0] = offset - save;
+                offsets[1] = save;
         }
         return offset;
     }
+    }
 
     private int getTransitionIndex(long date, int type) {
         int low = 0;
         int high = transitions.length - 1;
 

@@ -500,12 +505,14 @@
 
         // beyond the transition table
         SimpleTimeZone tz = getLastRule();
         if (tz != null) {
             return tz.inDaylightTime(date);
+        } else {
+            // use the last transition
+            return (transitions[transitions.length - 1] & DST_MASK) != 0;
        }
-        return false;
     }
 
     /**
      * Returns the amount of time in milliseconds that the clock is advanced
      * during daylight saving time is in effect in its last daylight saving time rule.
< prev index next >