code: public void setTextFieldToValidStateIfNeeded() {
          // Find out if the text field needs to be set to the last valid date or not.
          // The text field needs to be set whenever its text does not match the standard format
          // for the last valid date.
          String standardDateString = zGetStandardTextFieldDateString(lastValidDate);
          String textFieldString = dateTextField.getText();
          if (!standardDateString.equals(textFieldString)) {
              // Overwrite the text field with the last valid date.
              // This will clear the text field if the last valid date is null.
              setDate(lastValidDate);
          }
      }
docs: setTextFieldToValidStateIfNeeded,
  
  This function will check the contents of the text field, and when needed, will set the text
  to match the "last valid date" in a standardized valid format. This function is automatically
  called whenever the date picker text field loses focus, or at other times when the text must
  be set to a valid state. It is not expected that the programmer will normally need to call
  this function directly.
  
  This function has two possible effects: 1) If the current text is already valid and is in the
  standard format, then this will do nothing. If the text is not valid, or if the text is not
  in the standard format, then: 2) This will replace the invalid text in the text field with a
  standard date field text string that matches the last valid date.