CalendarBusinessDateUtils { public static LocalDate nthGoodBusinessDate(final LocalDate startingDate, final Calendar calendar, final int numberDate) { ArgumentChecker.isTrue(numberDate >= 1, "At least one roll date"); LocalDate nthDate = nextGoodBusinessDate(startingDate, calendar); for (int loopNumber = 1; loopNumber < numberDate; loopNumber++) { nthDate = nextGoodBusinessDate(nthDate.plusDays(1), calendar); } return nthDate; }  static LocalDate nextGoodBusinessDate(final LocalDate startingDate, final Calendar calendar); static LocalDate nextNonGoodBusinessDate(final LocalDate startingDate, final Calendar calendar); static LocalDate nthGoodBusinessDate(final LocalDate startingDate, final Calendar calendar, final int numberDate); static LocalDate nthNonGoodBusinessDate(final LocalDate startingDate, final Calendar calendar, final int numberDate);  }
@Test public void nthGoodBusinessDate() { LocalDate startDate = LocalDate.of(2013, 12, 4); LocalDate firstGoodComputed = CalendarBusinessDateUtils.nthGoodBusinessDate(startDate, ECB, 1); assertEquals("CalendarBusinessDateUtils: nthGoodBusinessDate", startDate, firstGoodComputed); LocalDate startDate2 = LocalDate.of(2013, 12, 11); LocalDate firstGoodComputed2 = CalendarBusinessDateUtils.nthGoodBusinessDate(startDate2, ECB, 1); LocalDate firstGoodExpected2 = startDate2.plusDays(1); assertEquals("CalendarBusinessDateUtils: nthGoodBusinessDate", firstGoodExpected2, firstGoodComputed2); int number = 15; LocalDate nthGoodComputed = CalendarBusinessDateUtils.nthGoodBusinessDate(startDate, ECB, number); LocalDate nthGoodExpected = startDate.plusDays(number); assertEquals("CalendarBusinessDateUtils: nthGoodBusinessDate", nthGoodExpected, nthGoodComputed); int number2 = 45; LocalDate nthGoodComputed2 = CalendarBusinessDateUtils.nthGoodBusinessDate(startDate, ECB, number2); LocalDate nthGoodExpected2 = startDate.plusDays(number2 + 1); assertEquals("CalendarBusinessDateUtils: nthGoodBusinessDate", nthGoodExpected2, nthGoodComputed2); }