The DatePicker control allows the user to enter a date as text or to select a date from a calendar popup. The calendar is based on either the standard ISO-8601 chronology or any of the other chronology classes defined in the java.time.chrono package.
The value
property represents the
currently selected java.time.LocalDate
. An initial date can
be set via the constructor
or by calling setValue(LocalDate)
. The
default value is null.
final DatePicker datePicker = new DatePicker();
datePicker.setOnAction(new EventHandler() {
public void handle(Event t) {
LocalDate date = datePicker.getValue();
System.err.println("Selected date: " + date);
}
});
The chronology
property specifies a
calendar system to be used for parsing, displaying, and choosing
dates.
The value
property is always defined in
the ISO calendar system, however, so applications based on a
different chronology may use the conversion methods provided in the
java.time.chrono.Chronology
API to get or set the
corresponding java.time.chrono.ChronoLocalDate
value. For
example:
LocalDate isoDate = datePicker.getValue();
ChronoLocalDate chronoDate =
((isoDate != null) ? datePicker.getChronology().date(isoDate) : null);
System.err.println("Selected date: " + chronoDate);
extends