jdk/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java
changeset 19841 15c8e97d6a14
parent 19030 32f129cb6351
child 20518 dde564773845
equal deleted inserted replaced
19822:4e10a58fa28f 19841:15c8e97d6a14
    92  * It does not store or represent a time-zone. For example, the value
    92  * It does not store or represent a time-zone. For example, the value
    93  * "2nd October 2007 at 13:45.30.123456789" can be stored in an {@code ChronoLocalDateTime}.
    93  * "2nd October 2007 at 13:45.30.123456789" can be stored in an {@code ChronoLocalDateTime}.
    94  *
    94  *
    95  * @implSpec
    95  * @implSpec
    96  * This class is immutable and thread-safe.
    96  * This class is immutable and thread-safe.
    97  *
    97  * @serial
    98  * @param <D> the concrete type for the date of this date-time
    98  * @param <D> the concrete type for the date of this date-time
    99  * @since 1.8
    99  * @since 1.8
   100  */
   100  */
   101 final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
   101 final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
   102         implements  ChronoLocalDateTime<D>, Temporal, TemporalAdjuster, Serializable {
   102         implements  ChronoLocalDateTime<D>, Temporal, TemporalAdjuster, Serializable {
   155     static final long NANOS_PER_DAY = NANOS_PER_HOUR * HOURS_PER_DAY;
   155     static final long NANOS_PER_DAY = NANOS_PER_HOUR * HOURS_PER_DAY;
   156 
   156 
   157     /**
   157     /**
   158      * The date part.
   158      * The date part.
   159      */
   159      */
   160     private final D date;
   160     private final transient D date;
   161     /**
   161     /**
   162      * The time part.
   162      * The time part.
   163      */
   163      */
   164     private final LocalTime time;
   164     private final transient LocalTime time;
   165 
   165 
   166     //-----------------------------------------------------------------------
   166     //-----------------------------------------------------------------------
   167     /**
   167     /**
   168      * Obtains an instance of {@code ChronoLocalDateTime} from a date and time.
   168      * Obtains an instance of {@code ChronoLocalDateTime} from a date and time.
   169      *
   169      *
   400         }
   400         }
   401         return unit.between(this, endDateTime);
   401         return unit.between(this, endDateTime);
   402     }
   402     }
   403 
   403 
   404     //-----------------------------------------------------------------------
   404     //-----------------------------------------------------------------------
       
   405     /**
       
   406      * Writes the ChronoLocalDateTime using a
       
   407      * <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
       
   408      * @serialData
       
   409      * <pre>
       
   410      *  out.writeByte(2);              // identifies a ChronoLocalDateTime
       
   411      *  out.writeObject(toLocalDate());
       
   412      *  out.witeObject(toLocalTime());
       
   413      * </pre>
       
   414      *
       
   415      * @return the instance of {@code Ser}, not null
       
   416      */
   405     private Object writeReplace() {
   417     private Object writeReplace() {
   406         return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
   418         return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
   407     }
   419     }
   408 
   420 
   409     /**
   421     /**
   410      * Defend against malicious streams.
   422      * Defend against malicious streams.
   411      * @return never
   423      * @return never
   412      * @throws InvalidObjectException always
   424      * @throws InvalidObjectException always
   413      */
   425      */
   414     private Object readResolve() throws ObjectStreamException {
   426     private Object readResolve() throws InvalidObjectException {
   415         throw new InvalidObjectException("Deserialization via serialization delegate");
   427         throw new InvalidObjectException("Deserialization via serialization delegate");
   416     }
   428     }
   417 
   429 
   418     void writeExternal(ObjectOutput out) throws IOException {
   430     void writeExternal(ObjectOutput out) throws IOException {
   419         out.writeObject(date);
   431         out.writeObject(date);