code: public void setSelectedDate(@NonNull Calendar date) {
          final int count = getAdapter().getCount() - 1;
          int itemPosition = -1;
          for(int i=0; i<count; i++) {
              if(getAdapter().getItem(i).equals(date)) { // because DateItem deeply compares to calendar
                  itemPosition = i;
                  break;
              }
          }
          if(itemPosition >= 0)
              setSelection(itemPosition);
          else if(showWeekdayNames) {
              final long MILLIS_IN_DAY = 1000*60*60*24;
              final long dateDifference = (date.getTimeInMillis()/MILLIS_IN_DAY)
                      - (Calendar.getInstance().getTimeInMillis()/MILLIS_IN_DAY);
              if(dateDifference>0 && dateDifference<7) { // if the date is within the next week:
                  // construct a temporary DateItem to select:
                  final int day = date.get(Calendar.DAY_OF_WEEK);
  
                  // Because these items are always temporarily selected, we can safely assume that
                  // they will never appear in the spinner dropdown. When a FLAG_NUMBERS is set, we
                  // want these items to have the date as secondary text in a short format.
                  selectTemporary(new DateItem(getWeekDay(day, R.string.date_only_weekday), formatSecondaryDate(date), date, NO_ID));
              } else {
                  // show the date as a full text, using the current DateFormat:
                  selectTemporary(new DateItem(formatDate(date), date, NO_ID));
              }
          }
          else {
              // show the date as a full text, using the current DateFormat:
              selectTemporary(new DateItem(formatDate(date), date, NO_ID));
          }
      }
docs: Sets the Spinner's selection as date. If the date was not in the possible selections, a temporary
  item is created and passed to selectTemporary().
  @param date The date to be selected.