jdk/src/share/classes/java/time/ZoneOffset.java
changeset 19841 15c8e97d6a14
parent 19030 32f129cb6351
child 20520 0952771e3e25
equal deleted inserted replaced
19822:4e10a58fa28f 19841:15c8e97d6a14
    68 
    68 
    69 import java.io.DataInput;
    69 import java.io.DataInput;
    70 import java.io.DataOutput;
    70 import java.io.DataOutput;
    71 import java.io.IOException;
    71 import java.io.IOException;
    72 import java.io.InvalidObjectException;
    72 import java.io.InvalidObjectException;
    73 import java.io.ObjectStreamException;
    73 import java.io.InvalidObjectException;
    74 import java.io.Serializable;
    74 import java.io.Serializable;
    75 import java.time.temporal.ChronoField;
    75 import java.time.temporal.ChronoField;
    76 import java.time.temporal.Temporal;
    76 import java.time.temporal.Temporal;
    77 import java.time.temporal.TemporalAccessor;
    77 import java.time.temporal.TemporalAccessor;
    78 import java.time.temporal.TemporalAdjuster;
    78 import java.time.temporal.TemporalAdjuster;
   738 
   738 
   739     // -----------------------------------------------------------------------
   739     // -----------------------------------------------------------------------
   740     /**
   740     /**
   741      * Writes the object using a
   741      * Writes the object using a
   742      * <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
   742      * <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
       
   743      * @serialData
   743      * <pre>
   744      * <pre>
   744      *  out.writeByte(8);  // identifies this as a ZoneOffset
   745      *  out.writeByte(8);                  // identifies a ZoneOffset
   745      *  int offsetByte = totalSeconds % 900 == 0 ? totalSeconds / 900 : 127;
   746      *  int offsetByte = totalSeconds % 900 == 0 ? totalSeconds / 900 : 127;
   746      *  out.writeByte(offsetByte);
   747      *  out.writeByte(offsetByte);
   747      *  if (offsetByte == 127) {
   748      *  if (offsetByte == 127) {
   748      *    out.writeInt(totalSeconds);
   749      *      out.writeInt(totalSeconds);
   749      *  }
   750      *  }
   750      * </pre>
   751      * </pre>
   751      *
   752      *
   752      * @return the instance of {@code Ser}, not null
   753      * @return the instance of {@code Ser}, not null
   753      */
   754      */
   758     /**
   759     /**
   759      * Defend against malicious streams.
   760      * Defend against malicious streams.
   760      * @return never
   761      * @return never
   761      * @throws InvalidObjectException always
   762      * @throws InvalidObjectException always
   762      */
   763      */
   763     private Object readResolve() throws ObjectStreamException {
   764     private Object readResolve() throws InvalidObjectException {
   764         throw new InvalidObjectException("Deserialization via serialization delegate");
   765         throw new InvalidObjectException("Deserialization via serialization delegate");
   765     }
   766     }
   766 
   767 
   767     @Override
   768     @Override
   768     void write(DataOutput out) throws IOException {
   769     void write(DataOutput out) throws IOException {