class IMMDateLogic {

  public static LocalDate getNextIMMDate(final LocalDate date) {

    final int day = date.getDayOfMonth();
    final int month = date.getMonthValue();
    final int year = date.getYear();
    if (month % 3 == 0) { //in an IMM month
      if (day < IMM_DAY) {
        return LocalDate.of(year, month, IMM_DAY);
      } else {
        if (month != 12) {
          return LocalDate.of(year, month + 3, IMM_DAY);
        } else {
          return LocalDate.of(year + 1, IMM_MONTHS[0], IMM_DAY);
        }
      }
    } else {
      return LocalDate.of(year, IMM_MONTHS[month / 3], IMM_DAY);
    }
  }

}