@Override public final long getLong( TemporalField field ) { return temporal().getLong( field ); }
@Override public long between(Temporal temporal1, Temporal temporal2) { switch(this) { case WEEK_BASED_YEARS: return Jdk8Methods.safeSubtract(temporal2.getLong(WEEK_BASED_YEAR), temporal1.getLong(WEEK_BASED_YEAR)); case QUARTER_YEARS: return temporal1.until(temporal2, MONTHS) / 3; default: throw new IllegalStateException("Unreachable"); } }
@Override public final long getLong( TemporalField field ) { return temporal().getLong( field ); }
private static final long millis(Temporal temporal) { // java.sql.* temporal types: if (temporal instanceof LocalDate) { return Date.valueOf((LocalDate) temporal).getTime(); } else if (temporal instanceof LocalTime) { return Time.valueOf((LocalTime) temporal).getTime(); } else if (temporal instanceof LocalDateTime) { return Timestamp.valueOf((LocalDateTime) temporal).getTime(); } // OffsetDateTime else if (temporal.isSupported(INSTANT_SECONDS)) { return 1000 * temporal.getLong(INSTANT_SECONDS) + temporal.getLong(MILLI_OF_SECOND); } // OffsetTime else if (temporal.isSupported(MILLI_OF_DAY)) { return temporal.getLong(MILLI_OF_DAY); } throw fail(temporal, Long.class); }
@SuppressWarnings("unchecked") @Override public <R extends Temporal> R adjustInto(R temporal, long newValue) { long curValue = getFrom(temporal); range().checkValidValue(newValue, this); return (R) temporal.with(DAY_OF_YEAR, temporal.getLong(DAY_OF_YEAR) + (newValue - curValue)); } @Override
@SuppressWarnings("unchecked") @Override public <R extends Temporal> R adjustInto(R temporal, long newValue) { long curValue = getFrom(temporal); range().checkValidValue(newValue, this); return (R) temporal.with(MONTH_OF_YEAR, temporal.getLong(MONTH_OF_YEAR) + (newValue - curValue) * 3); } },