388 return Math.addExact(amount, time.until(end.toLocalTime(), unit));
389 }
390 ChronoLocalDate endDate = end.toLocalDate();
391 if (end.toLocalTime().isBefore(time)) {
392 endDate = endDate.minus(1, ChronoUnit.DAYS);
393 }
394 return date.until(endDate, unit);
395 }
396 Objects.requireNonNull(unit, "unit");
397 return unit.between(this, end);
398 }
399
400 //-----------------------------------------------------------------------
401 /**
402 * Writes the ChronoLocalDateTime using a
403 * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
404 * @serialData
405 * <pre>
406 * out.writeByte(2); // identifies a ChronoLocalDateTime
407 * out.writeObject(toLocalDate());
408 * out.witeObject(toLocalTime());
409 * </pre>
410 *
411 * @return the instance of {@code Ser}, not null
412 */
413 @java.io.Serial
414 private Object writeReplace() {
415 return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
416 }
417
418 /**
419 * Defend against malicious streams.
420 *
421 * @param s the stream to read
422 * @throws InvalidObjectException always
423 */
424 @java.io.Serial
425 private void readObject(ObjectInputStream s) throws InvalidObjectException {
426 throw new InvalidObjectException("Deserialization via serialization delegate");
427 }
428
|
388 return Math.addExact(amount, time.until(end.toLocalTime(), unit));
389 }
390 ChronoLocalDate endDate = end.toLocalDate();
391 if (end.toLocalTime().isBefore(time)) {
392 endDate = endDate.minus(1, ChronoUnit.DAYS);
393 }
394 return date.until(endDate, unit);
395 }
396 Objects.requireNonNull(unit, "unit");
397 return unit.between(this, end);
398 }
399
400 //-----------------------------------------------------------------------
401 /**
402 * Writes the ChronoLocalDateTime using a
403 * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
404 * @serialData
405 * <pre>
406 * out.writeByte(2); // identifies a ChronoLocalDateTime
407 * out.writeObject(toLocalDate());
408 * out.writeObject(toLocalTime());
409 * </pre>
410 *
411 * @return the instance of {@code Ser}, not null
412 */
413 @java.io.Serial
414 private Object writeReplace() {
415 return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
416 }
417
418 /**
419 * Defend against malicious streams.
420 *
421 * @param s the stream to read
422 * @throws InvalidObjectException always
423 */
424 @java.io.Serial
425 private void readObject(ObjectInputStream s) throws InvalidObjectException {
426 throw new InvalidObjectException("Deserialization via serialization delegate");
427 }
428
|