Class DateTimePicker
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<DateTimePicker>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<DateTimePicker>,com.vaadin.flow.component.FocusNotifier<DateTimePicker>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,,LocalDateTime>, LocalDateTime> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,,LocalDateTime>, LocalDateTime> com.vaadin.flow.component.shared.HasAutoOpen,com.vaadin.flow.component.shared.HasClientValidation,com.vaadin.flow.component.shared.HasOverlayClassName,com.vaadin.flow.component.shared.HasThemeVariant<DateTimePickerVariant>,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.data.binder.HasValidator<LocalDateTime>,Serializable
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
com.vaadin.flow.component.shared.HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DateTimePicker(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with aHasValue.ValueChangeListener.DateTimePicker(String label) Convenience constructor to create a date time picker with a label.DateTimePicker(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with aHasValue.ValueChangeListenerand a label.DateTimePicker(String label, LocalDateTime initialDateTime) Convenience constructor to create a date time picker with a pre-selected date and time in current UI locale format and a label.DateTimePicker(String label, LocalDateTime initialDateTime, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with a pre-selected date and time in current UI locale format, aHasValue.ValueChangeListenerand a label.DateTimePicker(LocalDateTime initialDateTime) Convenience constructor to create a date time picker with a pre-selected date time in current UI locale format.DateTimePicker(LocalDateTime initialDateTime, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with a pre-selected date time in current UI locale format and aHasValue.ValueChangeListener.DateTimePicker(LocalDateTime initialDateTime, Locale locale) Convenience constructor to create a date time picker with pre-selected date time and locale setup. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddThemeName(String themeName) Adds a theme name to this component.voidaddThemeNames(String... themeNames) Adds one or more theme names to this component.com.vaadin.flow.shared.RegistrationaddValidationStatusChangeListener(com.vaadin.flow.data.binder.ValidationStatusChangeListener<LocalDateTime> listener) Gets the internationalization object previously set for this component.Gets the placeholder string of the date field.com.vaadin.flow.data.binder.Validator<LocalDateTime>getLabel()Gets the label of this field.Gets the Locale for this DateTimePickergetMax()Gets the maximum date and time in the date time picker.getMin()Gets the minimum date and time in the date time picker.getStep()Gets the step of the time picker.Gets the placeholder string of the time field.booleanGet the state ofshowWeekNumbersproperty of the date picker.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) booleanremoveThemeName(String themeName) Removes a theme name from this component.voidremoveThemeNames(String... themeNames) Removes one or more theme names from component.voidsetAutoOpen(boolean autoOpen) When auto open is enabled, the dropdown will open when the field is clicked.voidSets the internationalization properties for the date picker inside this component.voidsetDatePlaceholder(String placeholder) Sets a placeholder string for the date field.voidSets the label for this field.voidSet the Locale for the DateTimePicker.voidsetMax(LocalDateTime max) Sets the maximum date and time in the date time picker.voidsetMin(LocalDateTime min) Sets the minimum date and time in the date time picker.voidsetReadOnly(boolean readOnly) voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) Sets whether the date time picker is marked as input required.voidSets thestepproperty of the time picker using duration.voidsetThemeName(String themeName) Sets the theme names of this component.voidsetThemeName(String themeName, boolean set) Sets or removes the given theme name for this component.voidsetTimePlaceholder(String placeholder) Set a placeholder string for the time field.voidsetValue(LocalDateTime value) Sets the selected date and time value of the component.voidsetWeekNumbersVisible(boolean weekNumbersVisible) Show or hide the week numbers in the date picker.protected voidvalidate()Performs server-side validation of the current value.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasAutoOpen
isAutoOpenMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.shared.HasOverlayClassName
getOverlayClassName, setOverlayClassNameMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
getThemeName, getThemeNames, hasThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible
-
Constructor Details
-
DateTimePicker
public DateTimePicker()Default constructor. -
DateTimePicker
Convenience constructor to create a date time picker with a label.- Parameters:
label- the label describing the date time picker- See Also:
-
DateTimePicker
Convenience constructor to create a date time picker with a pre-selected date and time in current UI locale format and a label.- Parameters:
label- the label describing the date time pickerinitialDateTime- the pre-selected date time in the picker- See Also:
-
DateTimePicker
Convenience constructor to create a date time picker with a pre-selected date time in current UI locale format.- Parameters:
initialDateTime- the pre-selected date time in the picker
-
DateTimePicker
public DateTimePicker(com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with aHasValue.ValueChangeListener.- Parameters:
listener- the listener to receive value change events- See Also:
-
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
-
DateTimePicker
public DateTimePicker(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with aHasValue.ValueChangeListenerand a label.- Parameters:
label- the label describing the date time pickerlistener- the listener to receive value change events- See Also:
-
setLabel(String)AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
-
DateTimePicker
public DateTimePicker(LocalDateTime initialDateTime, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with a pre-selected date time in current UI locale format and aHasValue.ValueChangeListener.- Parameters:
initialDateTime- the pre-selected date time in the pickerlistener- the listener to receive value change events- See Also:
-
setValue(LocalDateTime)AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
-
DateTimePicker
public DateTimePicker(String label, LocalDateTime initialDateTime, com.vaadin.flow.component.HasValue.ValueChangeListener<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>> listener) Convenience constructor to create a date time picker with a pre-selected date and time in current UI locale format, aHasValue.ValueChangeListenerand a label.- Parameters:
label- the label describing the date time pickerinitialDateTime- the pre-selected date time in the pickerlistener- the listener to receive value change events- See Also:
-
setLabel(String)setValue(LocalDateTime)AbstractField.addValueChangeListener(HasValue.ValueChangeListener)
-
DateTimePicker
Convenience constructor to create a date time picker with pre-selected date time and locale setup.- Parameters:
initialDateTime- the pre-selected date time in the pickerlocale- the locale for the date time picker
-
-
Method Details
-
setValue
Sets the selected date and time value of the component. The value can be cleared by setting null.The value will be truncated to millisecond precision, as that is the maximum that the time picker supports. This means that
AbstractField.getValue()might return a different value than what was passed in.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>, LocalDateTime> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<DateTimePicker,LocalDateTime> - Parameters:
value- the LocalDateTime instance representing the selected date and time, or null
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>, LocalDateTime> - Specified by:
setReadOnlyin interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>, LocalDateTime>
-
setLabel
Sets the label for this field.- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel- Parameters:
label- the String value to set
-
getLabel
Gets the label of this field.- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel- Returns:
- the
labelproperty of the date time picker
-
setDatePlaceholder
Sets a placeholder string for the date field.- Parameters:
placeholder- the String value to set
-
getDatePlaceholder
Gets the placeholder string of the date field.- Returns:
- the
placeholderproperty of the date picker
-
setTimePlaceholder
Set a placeholder string for the time field.- Parameters:
placeholder- the String value to set
-
getTimePlaceholder
Gets the placeholder string of the time field.- Returns:
- the
placeholderproperty of the time picker
-
setStep
Sets thestepproperty of the time picker using duration. It specifies the intervals for the displayed items in the time picker dropdown and also the displayed time format.The set step needs to evenly divide a day or an hour and has to be larger than 0 milliseconds. By default, the format is
hh:mm(same as *Duration.ofHours(1)If the step is less than 60 seconds, the format will be changed to
hh:mm:ssand it can be inhh:mm:ss.fffformat, when the step is less than 1 second.NOTE: If the step is less than 900 seconds, the dropdown is hidden.
NOTE: changing the step to a larger duration can cause a new
HasValue.ValueChangeEventto be fired if some parts (eg. seconds) is discarded from the value.- Parameters:
step- the step to set, notnulland should divide a day or an hour evenly
-
getStep
Gets the step of the time picker.- Returns:
- the
stepproperty from the picker, unit seconds
-
setWeekNumbersVisible
public void setWeekNumbersVisible(boolean weekNumbersVisible) Show or hide the week numbers in the date picker. By default the week numbers are not shown.Set true to display ISO-8601 week numbers in the calendar.
Note that displaying of week numbers is only supported when i18n.firstDayOfWeek is 1 (Monday).
- Parameters:
weekNumbersVisible- the boolean value to set- See Also:
-
isWeekNumbersVisible
public boolean isWeekNumbersVisible()Get the state ofshowWeekNumbersproperty of the date picker.- Returns:
- the
showWeekNumbersproperty from the date picker
-
setLocale
Set the Locale for the DateTimePicker. The displayed date and time will be matched to the format used in that locale.- Parameters:
locale- the locale to set to the DateTimePicker, cannot be null
-
getLocale
Gets the Locale for this DateTimePicker- Overrides:
getLocalein classcom.vaadin.flow.component.Component- Returns:
- the locale used for this DateTimePicker
-
addThemeName
Adds a theme name to this component.- Specified by:
addThemeNamein interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeName- the theme name to add, notnull
-
removeThemeName
Removes a theme name from this component.- Specified by:
removeThemeNamein interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeName- the theme name to remove, notnull- Returns:
trueif the theme name was removed,falseif the theme list didn't contain the theme name
-
setThemeName
Sets the theme names of this component. This method overwrites any previous set theme names.- Specified by:
setThemeNamein interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeName- a space-separated string of theme names to set, or empty string to remove all theme names
-
setThemeName
Sets or removes the given theme name for this component.- Specified by:
setThemeNamein interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeName- the theme name to set or remove, notnullset-trueto set the theme name,falseto remove it
-
addThemeNames
Adds one or more theme names to this component. Multiple theme names can be specified by using multiple parameters.- Specified by:
addThemeNamesin interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeNames- the theme name or theme names to be added to the component
-
removeThemeNames
Removes one or more theme names from component. Multiple theme names can be specified by using multiple parameters.- Specified by:
removeThemeNamesin interfacecom.vaadin.flow.component.HasTheme- Parameters:
themeNames- the theme name or theme names to be removed from the component
-
getDefaultValidator
- Specified by:
getDefaultValidatorin interfacecom.vaadin.flow.data.binder.HasValidator<LocalDateTime>
-
addValidationStatusChangeListener
public com.vaadin.flow.shared.Registration addValidationStatusChangeListener(com.vaadin.flow.data.binder.ValidationStatusChangeListener<LocalDateTime> listener) - Specified by:
addValidationStatusChangeListenerin interfacecom.vaadin.flow.data.binder.HasValidator<LocalDateTime>
-
validate
protected void validate()Performs server-side validation of the current value. This is needed because it is possible to circumvent the client-side validation constraints using browser development tools. -
setMin
Sets the minimum date and time in the date time picker. Dates and times before that will be disabled in the popups.- Parameters:
min- the minimum date and time that is allowed to be set, ornullto remove any minimum constraints
-
getMin
Gets the minimum date and time in the date time picker. Dates and times before that will be disabled in the popups.- Returns:
- the minimum date and time that is allowed to be set, or
nullif there's no minimum
-
setMax
Sets the maximum date and time in the date time picker. Dates and times above that will be disabled in the popups.- Parameters:
max- the maximum date and time that is allowed to be set, ornullto remove any minimum constraints
-
getMax
Gets the maximum date and time in the date time picker. Dates and times above that will be disabled in the popups.- Returns:
- the maximum date and time that is allowed to be set, or
nullif there's no minimum
-
getDatePickerI18n
Gets the internationalization object previously set for this component. Note: updating the object content that is gotten from this method will not update the lang on the component if not set back usingsetDatePickerI18n(DatePickerI18n)- Returns:
- the i18n object. It will be
null, If the i18n properties weren't set.
-
setDatePickerI18n
Sets the internationalization properties for the date picker inside this component.- Parameters:
i18n- the internationalized properties, notnull
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) Sets whether the date time picker is marked as input required.- Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>, LocalDateTime> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>, LocalDateTime> - Parameters:
requiredIndicatorVisible- the value of the requiredIndicatorVisible to be set
-
setAutoOpen
public void setAutoOpen(boolean autoOpen) When auto open is enabled, the dropdown will open when the field is clicked.- Specified by:
setAutoOpenin interfacecom.vaadin.flow.component.shared.HasAutoOpen- Parameters:
autoOpen- Value for the auto open property,
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-