< prev index next >

src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java

Print this page



 173     ZoneOffsetTransition(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
 174         this.epochSecond = epochSecond;
 175         this.transition = LocalDateTime.ofEpochSecond(epochSecond, 0, offsetBefore);
 176         this.offsetBefore = offsetBefore;
 177         this.offsetAfter = offsetAfter;
 178     }
 179 
 180     //-----------------------------------------------------------------------
 181     /**
 182      * Defend against malicious streams.
 183      *
 184      * @param s the stream to read
 185      * @throws InvalidObjectException always
 186      */
 187     private void readObject(ObjectInputStream s) throws InvalidObjectException {
 188         throw new InvalidObjectException("Deserialization via serialization delegate");
 189     }
 190 
 191     /**
 192      * Writes the object using a
 193      * <a href="../../../serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
 194      * @serialData
 195      * Refer to the serialized form of
 196      * <a href="../../../serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
 197      * for the encoding of epoch seconds and offsets.
 198      * <pre style="font-size:1.0em">{@code
 199      *
 200      *   out.writeByte(2);                // identifies a ZoneOffsetTransition
 201      *   out.writeEpochSec(toEpochSecond);
 202      *   out.writeOffset(offsetBefore);
 203      *   out.writeOffset(offsetAfter);
 204      * }
 205      * </pre>
 206      * @return the replacing object, not null
 207      */
 208     private Object writeReplace() {
 209         return new Ser(Ser.ZOT, this);
 210     }
 211 
 212     /**
 213      * Writes the state to the stream.
 214      *
 215      * @param out  the output stream, not null
 216      * @throws IOException if an error occurs



 173     ZoneOffsetTransition(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
 174         this.epochSecond = epochSecond;
 175         this.transition = LocalDateTime.ofEpochSecond(epochSecond, 0, offsetBefore);
 176         this.offsetBefore = offsetBefore;
 177         this.offsetAfter = offsetAfter;
 178     }
 179 
 180     //-----------------------------------------------------------------------
 181     /**
 182      * Defend against malicious streams.
 183      *
 184      * @param s the stream to read
 185      * @throws InvalidObjectException always
 186      */
 187     private void readObject(ObjectInputStream s) throws InvalidObjectException {
 188         throw new InvalidObjectException("Deserialization via serialization delegate");
 189     }
 190 
 191     /**
 192      * Writes the object using a
 193      * <a href="{@docRoot}/serialized-form.html#java.time.zone.Ser">dedicated serialized form</a>.
 194      * @serialData
 195      * Refer to the serialized form of
 196      * <a href="{@docRoot}/serialized-form.html#java.time.zone.ZoneRules">ZoneRules.writeReplace</a>
 197      * for the encoding of epoch seconds and offsets.
 198      * <pre style="font-size:1.0em">{@code
 199      *
 200      *   out.writeByte(2);                // identifies a ZoneOffsetTransition
 201      *   out.writeEpochSec(toEpochSecond);
 202      *   out.writeOffset(offsetBefore);
 203      *   out.writeOffset(offsetAfter);
 204      * }
 205      * </pre>
 206      * @return the replacing object, not null
 207      */
 208     private Object writeReplace() {
 209         return new Ser(Ser.ZOT, this);
 210     }
 211 
 212     /**
 213      * Writes the state to the stream.
 214      *
 215      * @param out  the output stream, not null
 216      * @throws IOException if an error occurs


< prev index next >