IMMDateLogic { public static LocalDate[] getIMMDateSet(final LocalDate baseIMMDate, final Period[] tenors) { ArgumentChecker.notNull(baseIMMDate, "startIMMDate"); ArgumentChecker.noNulls(tenors, "tenors"); final int n = tenors.length; ArgumentChecker.isTrue(isIMMDate(baseIMMDate), "start is not an IMM date"); final LocalDate nextIMM = baseIMMDate; final LocalDate[] res = new LocalDate[n]; for (int i = 0; i < n; i++) { res[i] = nextIMM.plus(tenors[i]); } return res; }  static boolean isIMMDate(final LocalDate date); static boolean isIndexRollDate(final LocalDate date); static LocalDate[] getIMMDateSet(final LocalDate baseIMMDate, final Period[] tenors); static LocalDate[] getIMMDateSet(final LocalDate startIMMDate, final int size); static LocalDate getNextIMMDate(final LocalDate date); static LocalDate getPrevIMMDate(final LocalDate date); static LocalDate getNextIndexRollDate(final LocalDate date);  }
@Test public void immSetTest() { final LocalDate date = LocalDate.of(2013, Month.MARCH, 20); final int n = 5; final LocalDate[] immDates = getIMMDateSet(date, n); assertTrue(immDates.length == n); assertEquals(date, immDates[0]); assertEquals(LocalDate.of(2013, Month.JUNE, 20), immDates[1]); assertEquals(LocalDate.of(2013, Month.SEPTEMBER, 20), immDates[2]); assertEquals(LocalDate.of(2013, Month.DECEMBER, 20), immDates[3]); assertEquals(LocalDate.of(2014, Month.MARCH, 20), immDates[4]); }