Class DatePicker
java.lang.Object
- All Implemented Interfaces:
Styleable
,EventTarget
,Skinnable
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 LocalDate
. An initial date can
be set via the constructor
or by calling setValue(LocalDate)
. The
default value is null.
DatePicker datePicker = new DatePicker();
datePicker.setOnAction(e -> {
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
Chronology
API to get or set the
corresponding ChronoLocalDate
value. For
example:
LocalDate isoDate = datePicker.getValue();
ChronoLocalDate chronoDate =
((isoDate != null) ? datePicker.getChronology().date(isoDate) : null);
System.err.println("Selected date: " + chronoDate);
- Since:
- JavaFX 8.0
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty
<Chronology> The calendar system used for parsing, displaying, and choosing dates in the DatePicker control.final ObjectProperty
<StringConverter<LocalDate>> Converts the input text to an object of type LocalDate and vice versa.final ObjectProperty
<Callback<DatePicker, DateCell>> A custom cell factory can be provided to customize individual day cells in the DatePicker popup.final ReadOnlyObjectProperty
<TextField> The editor for the DatePicker.final BooleanProperty
Whether the DatePicker popup should display a column showing week numbers.Properties declared in class javafx.scene.control.ComboBoxBase
armed, editable, onAction, onHidden, onHiding, onShowing, onShown, promptText, showing, value
Properties declared in class javafx.scene.control.Control
contextMenu, skin, tooltip
Properties declared in class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties declared in class javafx.scene.Parent
needsLayout
Properties declared in class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed,