@Test public void shouldAdjustLocalDateWithTwoDigitYears() { assertThat(ADJUSTER.adjustInto(localDateWithYear(00))).isEqualTo(localDateWithYear(2000)); assertThat(ADJUSTER.adjustInto(localDateWithYear(01))).isEqualTo(localDateWithYear(2001)); assertThat(ADJUSTER.adjustInto(localDateWithYear(10))).isEqualTo(localDateWithYear(2010)); assertThat(ADJUSTER.adjustInto(localDateWithYear(69))).isEqualTo(localDateWithYear(2069)); assertThat(ADJUSTER.adjustInto(localDateWithYear(70))).isEqualTo(localDateWithYear(1970)); assertThat(ADJUSTER.adjustInto(localDateWithYear(71))).isEqualTo(localDateWithYear(1971)); assertThat(ADJUSTER.adjustInto(localDateWithYear(99))).isEqualTo(localDateWithYear(1999)); }
@Test public void shouldAdjustLocalDateTimeWithTwoDigitYears() { assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(00))).isEqualTo(localDateTimeWithYear(2000)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(01))).isEqualTo(localDateTimeWithYear(2001)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(10))).isEqualTo(localDateTimeWithYear(2010)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(69))).isEqualTo(localDateTimeWithYear(2069)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(70))).isEqualTo(localDateTimeWithYear(1970)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(71))).isEqualTo(localDateTimeWithYear(1971)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(99))).isEqualTo(localDateTimeWithYear(1999)); }
@Test public void shouldNotAdjustLocalDateWithThreeDigitYears() { assertThat(ADJUSTER.adjustInto(localDateWithYear(-1))).isEqualTo(localDateWithYear(-1)); assertThat(ADJUSTER.adjustInto(localDateWithYear(100))).isEqualTo(localDateWithYear(100)); }
@Test public void shouldNotAdjustLocalDateTimeWithThreeDigitYears() { assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(-1))).isEqualTo(localDateTimeWithYear(-1)); assertThat(ADJUSTER.adjustInto(localDateTimeWithYear(100))).isEqualTo(localDateTimeWithYear(100)); }
@SuppressWarnings("unchecked") public T enforce(final T object) { if (myAdjuster != null) { return (T) myAdjuster.adjustInto(object); } else { return object; } }
@SuppressWarnings("unchecked") public T enforce(final T object) { if (myAdjuster != null) { return (T) myAdjuster.adjustInto(object); } else { return object; } }
@Override public DiscordianDate with(TemporalAdjuster adjuster) { return (DiscordianDate) adjuster.adjustInto(this); }
@Override public Symmetry010Date with(TemporalAdjuster adjuster) { return (Symmetry010Date) adjuster.adjustInto(this); }
@Override public Symmetry454Date with(TemporalAdjuster adjuster) { return (Symmetry454Date) adjuster.adjustInto(this); }
@Override public JulianDate with(TemporalAdjuster adjuster) { return (JulianDate) adjuster.adjustInto(this); }
@Override public BritishCutoverDate with(TemporalAdjuster adjuster) { return (BritishCutoverDate) adjuster.adjustInto(this); }
@Override public PaxDate with(TemporalAdjuster adjuster) { return (PaxDate) adjuster.adjustInto(this); }
@Override public AccountingDate with(TemporalAdjuster adjuster) { return (AccountingDate) adjuster.adjustInto(this); }
@Override public Temporal with(TemporalAdjuster adjuster) { return adjuster.adjustInto(this); }
@Override public InternationalFixedDate with(TemporalAdjuster adjuster) { return (InternationalFixedDate) adjuster.adjustInto(this); }
@Override public EthiopicDate with(TemporalAdjuster adjuster) { return (EthiopicDate) adjuster.adjustInto(this); }
@Override public CopticDate with(TemporalAdjuster adjuster) { return (CopticDate) adjuster.adjustInto(this); }
default Temporal with(TemporalAdjuster adjuster) { return adjuster.adjustInto(this); }
/** * Returns an adjusted copy of this instant. * <p> * This returns a new {@code Instant}, based on this one, with the date adjusted. * The adjustment takes place using the specified adjuster strategy object. * Read the documentation of the adjuster to understand what adjustment will be made. * <p> * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the * specified adjuster passing {@code this} as the argument. * <p> * This instance is immutable and unaffected by this method call. * * @param adjuster the adjuster to use, not null * @return an {@code Instant} based on {@code this} with the adjustment made, not null * @throws DateTimeException if the adjustment cannot be made * @throws ArithmeticException if numeric overflow occurs */ @Override public Instant with(TemporalAdjuster adjuster) { return (Instant) adjuster.adjustInto(this); }
/** * Returns an adjusted copy of this year. * <p> * This returns a new {@code Year}, based on this one, with the year adjusted. * The adjustment takes place using the specified adjuster strategy object. * Read the documentation of the adjuster to understand what adjustment will be made. * <p> * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the * specified adjuster passing {@code this} as the argument. * <p> * This instance is immutable and unaffected by this method call. * * @param adjuster the adjuster to use, not null * @return a {@code Year} based on {@code this} with the adjustment made, not null * @throws DateTimeException if the adjustment cannot be made * @throws ArithmeticException if numeric overflow occurs */ @Override public Year with(TemporalAdjuster adjuster) { return (Year) adjuster.adjustInto(this); }