code: private void setCorrectDay(Calendar date) {
  
          if (monthHasNotDay(date)) {
              date.set(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH));
          } else {
              date.set(Calendar.DAY_OF_MONTH, m_dayOfMonth);
          }
      }
docs: Set the correct day for the date with year and month already fixed.
  @param date the date, where year and month are already correct.