public class DatePicker extends Dialog<java.time.LocalDate>
LocalDate based on the selection of a given day and month in the initial
monthly view, and a given year in a yearly view.
Based on Material Design guidelines, views can be switched by clicking in the labels that define the year, the day and month. Inside each view, months can be navigated by swipe gestures from left to right or right to left, as well as by dragging them to the left or to the right. Years can be navigated by scrolling vertically
The final selected local date will be available in the Dialog result
property. Dialog.showAndWait() method will return an Optional
instance with this result.
Here is a typical implementation:
DatePicker datePicker = new DatePicker();
datePicker.showAndWait().ifPresent(System.out::println);
Selected local date can be also accessed through the
dateProperty() .
TimePicker,
Dialog| Type | Property | Description |
|---|---|---|
javafx.beans.property.ObjectProperty<java.time.LocalDate> |
date |
The
ObjectProperty with the selected
LocalDate |
| Constructor | Description |
|---|---|
DatePicker() |
Creates a new dialog, where the initial selected local date is the current
one from the system clock in the default time-zone
|
DatePicker(java.time.LocalDate date) |
Creates a new dialog using given local date
|
| Modifier and Type | Method | Description |
|---|---|---|
javafx.beans.property.ObjectProperty<java.time.LocalDate> |
dateProperty() |
The
ObjectProperty with the selected
LocalDate |
java.time.LocalDate |
getDate() |
Returns the selected
LocalDate |
void |
setDate(java.time.LocalDate value) |
Sets the
LocalDate |
autoHideProperty, buildEventDispatchChain, contentProperty, contentTextProperty, getButtons, getContent, getContentText, getGraphic, getId, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getTitle, getTitleText, graphicProperty, hide, idProperty, isAutoHide, isFullscreen, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, setAutoHide, setContent, setContentText, setGraphic, setId, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setResult, setTitle, setTitleText, showAndWait, showingProperty, titleProperty, titleTextPropertypublic final javafx.beans.property.ObjectProperty<java.time.LocalDate> dateProperty
ObjectProperty with the selected
LocalDategetDate(),
setDate(LocalDate)public DatePicker()
public DatePicker(java.time.LocalDate date)
date - the initial local datepublic final javafx.beans.property.ObjectProperty<java.time.LocalDate> dateProperty()
ObjectProperty with the selected
LocalDategetDate(),
setDate(LocalDate)public final java.time.LocalDate getDate()
LocalDateLocalDatepublic final void setDate(java.time.LocalDate value)
LocalDatevalue - The LocalDate to be set as selected date