< prev index next >

src/java.base/share/classes/java/util/SimpleTimeZone.java

Print this page




1225      * time.  Wall clock time is standard time for the onset rule, and
1226      * daylight time for the end rule.
1227      * @since 1.4
1228      */
1229     public static final int WALL_TIME = 0; // Zero for backward compatibility
1230 
1231     /**
1232      * Constant for a mode of start or end time specified as standard time.
1233      * @since 1.4
1234      */
1235     public static final int STANDARD_TIME = 1;
1236 
1237     /**
1238      * Constant for a mode of start or end time specified as UTC. European
1239      * Union rules are specified as UTC time, for example.
1240      * @since 1.4
1241      */
1242     public static final int UTC_TIME = 2;
1243 
1244     // Proclaim compatibility with 1.1

1245     static final long serialVersionUID = -403250971215465050L;
1246 
1247     // the internal serial version which says which version was written
1248     // - 0 (default) for version up to JDK 1.1.3
1249     // - 1 for version from JDK 1.1.4, which includes 3 new fields
1250     // - 2 for JDK 1.3, which includes 2 new fields
1251     static final int currentSerialVersion = 2;
1252 
1253     /**
1254      * The version of the serialized data on the stream.  Possible values:
1255      * <dl>
1256      * <dt><b>0</b> or not present on stream</dt>
1257      * <dd>
1258      * JDK 1.1.3 or earlier.
1259      * </dd>
1260      * <dt><b>1</b></dt>
1261      * <dd>
1262      * JDK 1.1.4 or later.  Includes three new fields: <code>startMode</code>,
1263      * <code>endMode</code>, and <code>dstSavings</code>.
1264      * </dd>


1619         startTime = times[0];
1620         endTime = times[1];
1621     }
1622 
1623     /**
1624      * Save the state of this object to a stream (i.e., serialize it).
1625      *
1626      * @serialData We write out two formats, a JDK 1.1 compatible format, using
1627      * <code>DOW_IN_MONTH_MODE</code> rules, in the required section, followed
1628      * by the full rules, in packed format, in the optional section.  The
1629      * optional section will be ignored by JDK 1.1 code upon stream in.
1630      * <p> Contents of the optional section: The length of a byte array is
1631      * emitted (int); this is 4 as of this release. The byte array of the given
1632      * length is emitted. The contents of the byte array are the true values of
1633      * the fields <code>startDay</code>, <code>startDayOfWeek</code>,
1634      * <code>endDay</code>, and <code>endDayOfWeek</code>.  The values of these
1635      * fields in the required section are approximate values suited to the rule
1636      * mode <code>DOW_IN_MONTH_MODE</code>, which is the only mode recognized by
1637      * JDK 1.1.
1638      */

1639     private void writeObject(ObjectOutputStream stream)
1640          throws IOException
1641     {
1642         // Construct a binary rule
1643         byte[] rules = packRules();
1644         int[] times = packTimes();
1645 
1646         // Convert to 1.1 FCS rules.  This step may cause us to lose information.
1647         makeRulesCompatible();
1648 
1649         // Write out the 1.1 FCS rules
1650         stream.defaultWriteObject();
1651 
1652         // Write out the binary rules in the optional data area of the stream.
1653         stream.writeInt(rules.length);
1654         stream.write(rules);
1655         stream.writeObject(times);
1656 
1657         // Recover the original rules.  This recovers the information lost
1658         // by makeRulesCompatible.
1659         unpackRules(rules);
1660         unpackTimes(times);
1661     }
1662 
1663     /**
1664      * Reconstitute this object from a stream (i.e., deserialize it).
1665      *
1666      * We handle both JDK 1.1
1667      * binary formats and full formats with a packed byte array.
1668      */

1669     private void readObject(ObjectInputStream stream)
1670          throws IOException, ClassNotFoundException
1671     {
1672         stream.defaultReadObject();
1673 
1674         if (serialVersionOnStream < 1) {
1675             // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
1676             // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
1677             // too much, so we assume SUNDAY, which actually works most of the time.
1678             if (startDayOfWeek == 0) {
1679                 startDayOfWeek = Calendar.SUNDAY;
1680             }
1681             if (endDayOfWeek == 0) {
1682                 endDayOfWeek = Calendar.SUNDAY;
1683             }
1684 
1685             // The variables dstSavings, startMode, and endMode are post-1.1, so they
1686             // won't be present if we're reading from a 1.1 stream.  Fix them up.
1687             startMode = endMode = DOW_IN_MONTH_MODE;
1688             dstSavings = millisPerHour;




1225      * time.  Wall clock time is standard time for the onset rule, and
1226      * daylight time for the end rule.
1227      * @since 1.4
1228      */
1229     public static final int WALL_TIME = 0; // Zero for backward compatibility
1230 
1231     /**
1232      * Constant for a mode of start or end time specified as standard time.
1233      * @since 1.4
1234      */
1235     public static final int STANDARD_TIME = 1;
1236 
1237     /**
1238      * Constant for a mode of start or end time specified as UTC. European
1239      * Union rules are specified as UTC time, for example.
1240      * @since 1.4
1241      */
1242     public static final int UTC_TIME = 2;
1243 
1244     // Proclaim compatibility with 1.1
1245     @java.io.Serial
1246     static final long serialVersionUID = -403250971215465050L;
1247 
1248     // the internal serial version which says which version was written
1249     // - 0 (default) for version up to JDK 1.1.3
1250     // - 1 for version from JDK 1.1.4, which includes 3 new fields
1251     // - 2 for JDK 1.3, which includes 2 new fields
1252     static final int currentSerialVersion = 2;
1253 
1254     /**
1255      * The version of the serialized data on the stream.  Possible values:
1256      * <dl>
1257      * <dt><b>0</b> or not present on stream</dt>
1258      * <dd>
1259      * JDK 1.1.3 or earlier.
1260      * </dd>
1261      * <dt><b>1</b></dt>
1262      * <dd>
1263      * JDK 1.1.4 or later.  Includes three new fields: <code>startMode</code>,
1264      * <code>endMode</code>, and <code>dstSavings</code>.
1265      * </dd>


1620         startTime = times[0];
1621         endTime = times[1];
1622     }
1623 
1624     /**
1625      * Save the state of this object to a stream (i.e., serialize it).
1626      *
1627      * @serialData We write out two formats, a JDK 1.1 compatible format, using
1628      * <code>DOW_IN_MONTH_MODE</code> rules, in the required section, followed
1629      * by the full rules, in packed format, in the optional section.  The
1630      * optional section will be ignored by JDK 1.1 code upon stream in.
1631      * <p> Contents of the optional section: The length of a byte array is
1632      * emitted (int); this is 4 as of this release. The byte array of the given
1633      * length is emitted. The contents of the byte array are the true values of
1634      * the fields <code>startDay</code>, <code>startDayOfWeek</code>,
1635      * <code>endDay</code>, and <code>endDayOfWeek</code>.  The values of these
1636      * fields in the required section are approximate values suited to the rule
1637      * mode <code>DOW_IN_MONTH_MODE</code>, which is the only mode recognized by
1638      * JDK 1.1.
1639      */
1640     @java.io.Serial
1641     private void writeObject(ObjectOutputStream stream)
1642          throws IOException
1643     {
1644         // Construct a binary rule
1645         byte[] rules = packRules();
1646         int[] times = packTimes();
1647 
1648         // Convert to 1.1 FCS rules.  This step may cause us to lose information.
1649         makeRulesCompatible();
1650 
1651         // Write out the 1.1 FCS rules
1652         stream.defaultWriteObject();
1653 
1654         // Write out the binary rules in the optional data area of the stream.
1655         stream.writeInt(rules.length);
1656         stream.write(rules);
1657         stream.writeObject(times);
1658 
1659         // Recover the original rules.  This recovers the information lost
1660         // by makeRulesCompatible.
1661         unpackRules(rules);
1662         unpackTimes(times);
1663     }
1664 
1665     /**
1666      * Reconstitute this object from a stream (i.e., deserialize it).
1667      *
1668      * We handle both JDK 1.1
1669      * binary formats and full formats with a packed byte array.
1670      */
1671     @java.io.Serial
1672     private void readObject(ObjectInputStream stream)
1673          throws IOException, ClassNotFoundException
1674     {
1675         stream.defaultReadObject();
1676 
1677         if (serialVersionOnStream < 1) {
1678             // Fix a bug in the 1.1 SimpleTimeZone code -- namely,
1679             // startDayOfWeek and endDayOfWeek were usually uninitialized.  We can't do
1680             // too much, so we assume SUNDAY, which actually works most of the time.
1681             if (startDayOfWeek == 0) {
1682                 startDayOfWeek = Calendar.SUNDAY;
1683             }
1684             if (endDayOfWeek == 0) {
1685                 endDayOfWeek = Calendar.SUNDAY;
1686             }
1687 
1688             // The variables dstSavings, startMode, and endMode are post-1.1, so they
1689             // won't be present if we're reading from a 1.1 stream.  Fix them up.
1690             startMode = endMode = DOW_IN_MONTH_MODE;
1691             dstSavings = millisPerHour;


< prev index next >