equal
deleted
inserted
replaced
184 * or the chronology is not equal this Chronology |
184 * or the chronology is not equal this Chronology |
185 */ |
185 */ |
186 static <R extends ChronoLocalDate> ChronoLocalDateTimeImpl<R> ensureValid(Chronology chrono, Temporal temporal) { |
186 static <R extends ChronoLocalDate> ChronoLocalDateTimeImpl<R> ensureValid(Chronology chrono, Temporal temporal) { |
187 @SuppressWarnings("unchecked") |
187 @SuppressWarnings("unchecked") |
188 ChronoLocalDateTimeImpl<R> other = (ChronoLocalDateTimeImpl<R>) temporal; |
188 ChronoLocalDateTimeImpl<R> other = (ChronoLocalDateTimeImpl<R>) temporal; |
189 if (chrono.equals(other.toLocalDate().getChronology()) == false) { |
189 if (chrono.equals(other.getChronology()) == false) { |
190 throw new ClassCastException("Chronology mismatch, required: " + chrono.getId() |
190 throw new ClassCastException("Chronology mismatch, required: " + chrono.getId() |
191 + ", actual: " + other.toLocalDate().getChronology().getId()); |
191 + ", actual: " + other.getChronology().getId()); |
192 } |
192 } |
193 return other; |
193 return other; |
194 } |
194 } |
195 |
195 |
196 /** |
196 /** |
369 //----------------------------------------------------------------------- |
369 //----------------------------------------------------------------------- |
370 @Override |
370 @Override |
371 public long until(Temporal endExclusive, TemporalUnit unit) { |
371 public long until(Temporal endExclusive, TemporalUnit unit) { |
372 Objects.requireNonNull(endExclusive, "endExclusive"); |
372 Objects.requireNonNull(endExclusive, "endExclusive"); |
373 @SuppressWarnings("unchecked") |
373 @SuppressWarnings("unchecked") |
374 ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) toLocalDate().getChronology().localDateTime(endExclusive); |
374 ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) getChronology().localDateTime(endExclusive); |
375 if (unit instanceof ChronoUnit) { |
375 if (unit instanceof ChronoUnit) { |
376 if (unit.isTimeBased()) { |
376 if (unit.isTimeBased()) { |
377 long amount = end.getLong(EPOCH_DAY) - date.getLong(EPOCH_DAY); |
377 long amount = end.getLong(EPOCH_DAY) - date.getLong(EPOCH_DAY); |
378 switch ((ChronoUnit) unit) { |
378 switch ((ChronoUnit) unit) { |
379 case NANOS: amount = Math.multiplyExact(amount, NANOS_PER_DAY); break; |
379 case NANOS: amount = Math.multiplyExact(amount, NANOS_PER_DAY); break; |