code: private int getNextVariableDay(int day, int lastDay, int dayOfWeek) // d659945
      {
          int nextDay = ADVANCE_TO_NEXT_MONTH;
  
          for (int i = 0; i < variableDayOfMonthRanges.size(); i++)
          {
              int result = variableDayOfMonthRanges.get(i).getNextDay(day, lastDay, dayOfWeek);
              if (result == day)
              {
                  return day;
              }
  
              nextDay = Math.min(nextDay, result);
          }
  
          return nextDay;
      }
docs: Returns the next day of the month after <tt>day</tt> that satisfies
  the variableDayOfMonthRanges constraint.
  
  @param day the current 0-based day of the month
  @param lastDay the current 0-based last day of the month
  @param dayOfWeek the current 0-based day of the week
  @return a value greater than or equal to <tt>day</tt>