aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java')
-rw-r--r--src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java b/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java
index 13b3a0e881..817ae85411 100644
--- a/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java
+++ b/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java
@@ -69,7 +69,6 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectStreamException;
import java.io.Serializable;
-import java.time.DateTimeException;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
@@ -369,15 +368,10 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
//-----------------------------------------------------------------------
@Override
- public long until(Temporal endDateTime, TemporalUnit unit) {
- if (endDateTime instanceof ChronoLocalDateTime == false) {
- throw new DateTimeException("Unable to calculate amount as objects are of two different types");
- }
+ public long until(Temporal endExclusive, TemporalUnit unit) {
+ Objects.requireNonNull(endExclusive, "endExclusive");
@SuppressWarnings("unchecked")
- ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) endDateTime;
- if (toLocalDate().getChronology().equals(end.toLocalDate().getChronology()) == false) {
- throw new DateTimeException("Unable to calculate amount as objects have different chronologies");
- }
+ ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) toLocalDate().getChronology().localDateTime(endExclusive);
if (unit instanceof ChronoUnit) {
if (unit.isTimeBased()) {
long amount = end.getLong(EPOCH_DAY) - date.getLong(EPOCH_DAY);
@@ -398,7 +392,8 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
}
return date.until(endDate, unit);
}
- return unit.between(this, endDateTime);
+ Objects.requireNonNull(unit, "unit");
+ return unit.between(this, end);
}
//-----------------------------------------------------------------------