DayOfMonthTemporalAdjuster implements TemporalAdjuster { @Override public Temporal adjustInto(final Temporal temporal) { ArgumentChecker.notNull(temporal, "temporal"); if (temporal.get(ChronoField.MONTH_OF_YEAR) == 2 && _day > 28) { return temporal.with(ChronoField.DAY_OF_MONTH, 28); } return temporal.with(ChronoField.DAY_OF_MONTH, _day); } DayOfMonthTemporalAdjuster(final int day); @Override Temporal adjustInto(final Temporal temporal);  }
@Test public void testFirstMonth() { final LocalDate date = LocalDate.of(2013, 1, 1); for (int i = 1; i < 30; i++) { final TemporalAdjuster ADJUSTER = new DayOfMonthTemporalAdjuster(i); assertEquals(LocalDate.of(2013, 1, i), ADJUSTER.adjustInto(date)); } }