code: private static void setOneWithFeb31ButtonClicked(ActionEvent e) {
          // Set date picker text.
          datePicker1.setText("February 31, 1950");
          // Display message.
          String message = "The datePicker1 text was set to: \"" + datePicker1.getText() + "\".\n";
          message += "Note: The stored date (the last valid date), did not change because"
              + " February never has 31 days.\n\n";
          message += getDatePickerOneDateText();
          panel.messageTextArea.setText(message);
      }
docs: setOneWithFeb31ButtonClicked, This sets the text in date picker one, to a nonexistent date
  (February 31st). The last valid date in a date picker is always saved. This is a programmatic
  demonstration of what happens when the user enters invalid text.