src/java.base/share/classes/sun/util/calendar/ZoneInfo.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 47216 71c04702a3d5
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   161     /**
   161     /**
   162      * True if the object has been modified after its instantiation.
   162      * True if the object has been modified after its instantiation.
   163      */
   163      */
   164     private transient boolean dirty = false;
   164     private transient boolean dirty = false;
   165 
   165 
       
   166     @java.io.Serial
   166     private static final long serialVersionUID = 2653134537216586139L;
   167     private static final long serialVersionUID = 2653134537216586139L;
   167 
   168 
   168     /**
   169     /**
   169      * A constructor.
   170      * A constructor.
   170      */
   171      */
   271             }
   272             }
   272             return offset;
   273             return offset;
   273         }
   274         }
   274 
   275 
   275         // beyond the transitions, delegate to SimpleTimeZone if there
   276         // beyond the transitions, delegate to SimpleTimeZone if there
   276         // is a rule; otherwise, return rawOffset.
   277         // is a rule; otherwise, return the offset of the last transition.
   277         SimpleTimeZone tz = getLastRule();
   278         SimpleTimeZone tz = getLastRule();
   278         if (tz != null) {
   279         if (tz != null) {
   279             int rawoffset = tz.getRawOffset();
   280             int rawoffset = tz.getRawOffset();
   280             long msec = date;
   281             long msec = date;
   281             if (type != UTC_TIME) {
   282             if (type != UTC_TIME) {
   291             if (offsets != null) {
   292             if (offsets != null) {
   292                 offsets[0] = rawoffset;
   293                 offsets[0] = rawoffset;
   293                 offsets[1] = dstoffset;
   294                 offsets[1] = dstoffset;
   294             }
   295             }
   295             return rawoffset + dstoffset;
   296             return rawoffset + dstoffset;
   296         }
   297         } else {
   297         int offset = getLastRawOffset();
   298             // use the last transition
   298         if (offsets != null) {
   299             long val = transitions[transitions.length - 1];
   299             offsets[0] = offset;
   300             int offset = this.offsets[(int)(val & OFFSET_MASK)] + rawOffsetDiff;
   300             offsets[1] = 0;
   301             if (offsets != null) {
   301         }
   302                 int dst = (int)((val >>> DST_NSHIFT) & 0xfL);
   302         return offset;
   303                 int save = (dst == 0) ? 0 : this.offsets[dst];
       
   304                 offsets[0] = offset - save;
       
   305                 offsets[1] = save;
       
   306             }
       
   307             return offset;
       
   308         }
   303     }
   309     }
   304 
   310 
   305     private int getTransitionIndex(long date, int type) {
   311     private int getTransitionIndex(long date, int type) {
   306         int low = 0;
   312         int low = 0;
   307         int high = transitions.length - 1;
   313         int high = transitions.length - 1;
   500 
   506 
   501         // beyond the transition table
   507         // beyond the transition table
   502         SimpleTimeZone tz = getLastRule();
   508         SimpleTimeZone tz = getLastRule();
   503         if (tz != null) {
   509         if (tz != null) {
   504             return tz.inDaylightTime(date);
   510             return tz.inDaylightTime(date);
   505        }
   511         } else {
   506         return false;
   512             // use the last transition
       
   513             return (transitions[transitions.length - 1] & DST_MASK) != 0;
       
   514         }
   507     }
   515     }
   508 
   516 
   509     /**
   517     /**
   510      * Returns the amount of time in milliseconds that the clock is advanced
   518      * Returns the amount of time in milliseconds that the clock is advanced
   511      * during daylight saving time is in effect in its last daylight saving time rule.
   519      * during daylight saving time is in effect in its last daylight saving time rule.
   717      */
   725      */
   718     public static Map<String, String> getAliasTable() {
   726     public static Map<String, String> getAliasTable() {
   719          return ZoneInfoFile.getAliasMap();
   727          return ZoneInfoFile.getAliasMap();
   720     }
   728     }
   721 
   729 
       
   730     @java.io.Serial
   722     private void readObject(ObjectInputStream stream)
   731     private void readObject(ObjectInputStream stream)
   723             throws IOException, ClassNotFoundException {
   732             throws IOException, ClassNotFoundException {
   724         stream.defaultReadObject();
   733         stream.defaultReadObject();
   725         // We don't know how this object from 1.4.x or earlier has
   734         // We don't know how this object from 1.4.x or earlier has
   726         // been mutated. So it should always be marked as `dirty'.
   735         // been mutated. So it should always be marked as `dirty'.