QuarterlyIMMRollDateAdjuster implements RollDateAdjuster { @Override public Temporal adjustInto(final Temporal temporal) { ArgumentChecker.notNull(temporal, "temporal"); final long month = temporal.getLong(ChronoField.MONTH_OF_YEAR); final long offset = month % 3L == 0L ? 0 : 3L - month % 3L; final Temporal temp = temporal.plus(offset, ChronoUnit.MONTHS); final Temporal immDateInMonth = temp.with(THIRD_WEDNESDAY); if (offset == 0L) { if (temp.getLong(ChronoField.DAY_OF_MONTH) > immDateInMonth.getLong(ChronoField.DAY_OF_MONTH)) { return temp.with(TemporalAdjusters.firstDayOfMonth()).plus(3L, ChronoUnit.MONTHS).with(THIRD_WEDNESDAY); } } return immDateInMonth; } private  QuarterlyIMMRollDateAdjuster(); static RollDateAdjuster getAdjuster(); @Override Temporal adjustInto(final Temporal temporal); @Override long getMonthsToAdjust(); @Override String getName();  }
@Test public void testFirstQuarter() { LocalDate date = LocalDate.of(2013, 1, 1); final LocalDate immDate = LocalDate.of(2013, 3, 20); while (!date.isAfter(immDate)) { assertEquals(immDate, ADJUSTER.adjustInto(date)); date = date.plusDays(1); } }
@Test public void testSecondQuarter() { LocalDate date = LocalDate.of(2013, 3, 21); final LocalDate immDate = LocalDate.of(2013, 6, 19); while(!date.isAfter(immDate)) { assertEquals(immDate, ADJUSTER.adjustInto(date)); date = date.plusDays(1); } }
@Test public void testThirdQuarterBefore() { LocalDate date = LocalDate.of(2013, 6, 20); final LocalDate immDate = LocalDate.of(2013, 9, 18); while(!date.isAfter(immDate)) { assertEquals(immDate, ADJUSTER.adjustInto(date)); date = date.plusDays(1); } }
@Test public void testFourthQuarter() { LocalDate date = LocalDate.of(2013, 9, 19); final LocalDate immDate = LocalDate.of(2013, 12, 18); while(!date.isAfter(immDate)) { assertEquals(immDate, ADJUSTER.adjustInto(date)); date = date.plusDays(1); } }
@Test public void testYearEnd() { LocalDate date = LocalDate.of(2013, 12, 19); final LocalDate endOfYear = LocalDate.of(2013, 12, 31); final LocalDate immDate = LocalDate.of(2014, 3, 19); while(!date.isAfter(endOfYear)) { assertEquals(immDate, ADJUSTER.adjustInto(date)); date = date.plusDays(1); } }