Get invalid input from DatePicker

I would like to react to invalid input into the DatePicker component, to do something along these lines:

datePicker.addInvalidChangeListener( e -> {
	String input = //get current text in text field of datePicker
	datePicker.setValue(getDateFromInput(input));
});

For that I would need access to the current content of the text field of the DatePicker, but I could not figure out a way to do it with the given API of DatePicker. Maybe there is something I am missing?

I’m also missing something :wink:

What I need:

  1. user types “1.1.1990”, but Locale.SK wants “1. 1. 1990”
  2. want to accept also date in different format
  3. as there is no way to set custom format, I want to handle invalid format
  4. but looks like there is no way to handle invalid format

so I’m also missing answer to this post :-/

Is it possible to get a raw user input string (instead of LocalDate) from the DatePicker?

I have the same problem with 16.0.2. The user will type in an invalid date, e.g. ‘121220’ close the select dialog and go to the next input field. The invalid date-string remains visible. The user selects an other record with no date, which triggers a clear() on the datepicker. But that does not remove the invalid string-value, making the user believe that the value was saved. In the bug report they stated that the invalid-value was copied to all lines :wink: I don’t see a handle in the DatePicker where I can remove or prevent the invalid date-string. Perhaps I am missing something ? Any insight would be appreciated.

(On a side note, the ‘setAutoOpen(…)’ also seems to be missing in 16.0.2)