@Tag(value="vaadin-date-time-picker") @NpmPackage(value="@vaadin/vaadin-date-time-picker", version="2.0.0") @JsModule(value="@vaadin/vaadin-date-time-picker/src/vaadin-date-time-picker.js") public class DateTimePicker extends AbstractField<DateTimePicker,LocalDateTime> implements HasStyle, HasSize, HasTheme, HasValidation, Focusable<DateTimePicker>, HasHelper
vaadin-date-time-picker web component.AbstractField.ComponentValueChangeEvent<C extends Component,V>BlurNotifier.BlurEvent<C extends Component>FocusNotifier.FocusEvent<C extends Component>HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>| Constructor and Description |
|---|
DateTimePicker()
Default constructor.
|
DateTimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
Convenience constructor to create a date time picker with a
ValueChangeListener. |
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,
HasValue.ValueChangeListener<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 a
ValueChangeListener. |
DateTimePicker(LocalDateTime initialDateTime,
Locale locale)
Convenience constructor to create a date time picker with pre-selected
date time and locale setup.
|
DateTimePicker(String label)
Convenience constructor to create a date time picker with a label.
|
DateTimePicker(String label,
HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
Convenience constructor to create a date time picker with a
ValueChangeListener and 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,
HasValue.ValueChangeListener<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, a
ValueChangeListener
and a label. |
| Modifier and Type | Method and Description |
|---|---|
void |
addThemeName(String themeName)
Adds a theme name to this component.
|
void |
addThemeNames(String... themeNames)
Adds one or more theme names to this component.
|
DatePicker.DatePickerI18n |
getDatePickerI18n()
Gets the internationalization object previously set for this component.
|
String |
getDatePlaceholder()
Gets the placeholder string of the date field.
|
String |
getErrorMessage()
Gets the error message to display when the input is invalid.
|
String |
getLabel()
Gets the label of this field.
|
Locale |
getLocale()
Gets the Locale for this DateTimePicker
|
LocalDateTime |
getMax()
Gets the maximum date and time in the date time picker.
|
LocalDateTime |
getMin()
Gets the minimum date and time in the date time picker.
|
Duration |
getStep()
Gets the step of the time picker.
|
String |
getTimePlaceholder()
Gets the placeholder string of the time field.
|
boolean |
isAutoOpen()
When auto open is enabled, the dropdown will open when the field is clicked.
|
boolean |
isInvalid()
Gets the validity indication of the date time picker output.
|
boolean |
isWeekNumbersVisible()
Get the state of
showWeekNumbers property of the date picker. |
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
boolean |
removeThemeName(String themeName)
Removes a theme name from this component.
|
void |
removeThemeNames(String... themeNames)
Removes one or more theme names from component.
|
void |
setAutoOpen(boolean autoOpen)
When auto open is enabled, the dropdown will open when the field is clicked.
|
void |
setDatePickerI18n(DatePicker.DatePickerI18n i18n)
Sets the internationalization properties for the date picker inside this
component.
|
void |
setDatePlaceholder(String placeholder)
Sets a placeholder string for the date field.
|
void |
setErrorMessage(String errorMessage)
Sets the error message to display when the input is invalid.
|
void |
setInvalid(boolean invalid)
Sets the validity indication of the date time picker output.
|
void |
setLabel(String label)
Sets the label for this field.
|
void |
setLocale(Locale locale)
Set the Locale for the DateTimePicker.
|
void |
setMax(LocalDateTime max)
Sets the maximum date and time in the date time picker.
|
void |
setMin(LocalDateTime min)
Sets the minimum date and time in the date time picker.
|
protected void |
setPresentationValue(LocalDateTime newPresentationValue)
Updates the presentation of this field to display the provided value.
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of this
HasValue to given mode. |
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets whether the date time picker is marked as input required.
|
void |
setStep(Duration step)
Sets the
step property of the time picker using duration. |
void |
setThemeName(String themeName)
Sets the theme names of this component.
|
void |
setThemeName(String themeName,
boolean set)
Sets or removes the given theme name for this component.
|
void |
setTimePlaceholder(String placeholder)
Set a placeholder string for the time field.
|
void |
setValue(LocalDateTime value)
Sets the value of this object.
|
void |
setWeekNumbersVisible(boolean weekNumbersVisible)
Show or hide the week numbers in the date picker.
|
protected void |
validate()
Performs server-side validation of the current value.
|
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamegetCssSize, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullgetThemeName, getThemeNames, hasThemeNameaddFocusShortcut, blur, focus, getTabIndex, setTabIndexaddBlurListeneraddFocusListenerisEnabled, setEnabledgetElementgetHelperComponent, getHelperText, setHelperComponent, setHelperTextisReadOnly, isRequiredIndicatorVisibleclear, getOptionalValueaddAttachListeneraddDetachListenerpublic DateTimePicker()
public DateTimePicker(String label)
label - the label describing the date time pickersetLabel(String)public DateTimePicker(String label, LocalDateTime initialDateTime)
label - the label describing the date time pickerinitialDateTime - the pre-selected date time in the pickersetValue(LocalDateTime),
setLabel(String)public DateTimePicker(LocalDateTime initialDateTime)
initialDateTime - the pre-selected date time in the pickerpublic DateTimePicker(HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
ValueChangeListener.listener - the listener to receive value change eventsAbstractField.addValueChangeListener(HasValue.ValueChangeListener)public DateTimePicker(String label, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
ValueChangeListener and a label.label - the label describing the date time pickerlistener - the listener to receive value change eventssetLabel(String),
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)public DateTimePicker(LocalDateTime initialDateTime, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
ValueChangeListener.initialDateTime - the pre-selected date time in the pickerlistener - the listener to receive value change eventssetValue(LocalDateTime),
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)public DateTimePicker(String label, LocalDateTime initialDateTime, HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>> listener)
ValueChangeListener
and a label.label - the label describing the date time pickerinitialDateTime - the pre-selected date time in the pickerlistener - the listener to receive value change eventssetLabel(String),
setValue(LocalDateTime),
AbstractField.addValueChangeListener(HasValue.ValueChangeListener)public DateTimePicker(LocalDateTime initialDateTime, Locale locale)
initialDateTime - the pre-selected date time in the pickerlocale - the locale for the date time pickerpublic void setValue(LocalDateTime value)
HasValuegetValue(), fires a value change event. May throw
IllegalArgumentException if the value is not acceptable.
Implementation note: the implementing class should document
whether null values are accepted or not, and override
HasValue.getEmptyValue() if the empty value is not null.
setValue in interface HasValue<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>,LocalDateTime>setValue in class AbstractField<DateTimePicker,LocalDateTime>value - the new valueprotected void setPresentationValue(LocalDateTime newPresentationValue)
AbstractField
If AbstractField.setModelValue(Object, boolean) is called from within this
method, the value of the last invocation will be used as the model value
instead of the value passed to this method. In this case
AbstractField.setPresentationValue(Object) will not be called again. Changing
the provided value might be useful if the provided value is sanitized.
See AbstractField for an overall description on the difference
between model values and presentation values.
setPresentationValue in class AbstractField<DateTimePicker,LocalDateTime>newPresentationValue - the new value to showpublic void setReadOnly(boolean readOnly)
HasValueHasValue to given mode. The user
can't change the value when in read-only mode.
A HasValue with a visual component in read-only mode typically
looks visually different to signal to the user that the value cannot be
edited.
setReadOnly in interface HasValue<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>,LocalDateTime>setReadOnly in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>,LocalDateTime>readOnly - a boolean value specifying whether the component is put
read-only mode or notpublic void setLabel(String label)
label - the String value to setpublic String getLabel()
label property of the date time pickerpublic void setDatePlaceholder(String placeholder)
placeholder - the String value to setpublic String getDatePlaceholder()
placeholder property of the date pickerpublic void setTimePlaceholder(String placeholder)
placeholder - the String value to setpublic String getTimePlaceholder()
placeholder property of the time pickerpublic void setStep(Duration step)
step property 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:ss and it can be in hh:mm:ss.fff format, 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.ValueChangeEvent to be fired
if some parts (eg. seconds) is discarded from the value.
step - the step to set, not null and should divide a day or
an hour evenlypublic Duration getStep()
step property from the picker, unit secondspublic void setWeekNumbersVisible(boolean weekNumbersVisible)
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).
weekNumbersVisible - the boolean value to set#setDatePickerI18n(DatePickerI18n),
DatePicker.DatePickerI18n.setFirstDayOfWeek(int)public boolean isWeekNumbersVisible()
showWeekNumbers property of the date picker.showWeekNumbers property from the date pickerpublic void setLocale(Locale locale)
locale - the locale to set to the DateTimePicker, cannot be nullpublic Locale getLocale()
public void addThemeName(String themeName)
addThemeName in interface HasThemethemeName - the theme name to add, not nullpublic boolean removeThemeName(String themeName)
removeThemeName in interface HasThemethemeName - the theme name to remove, not nulltrue if the theme name was removed,
false if the theme list didn't contain the theme
namepublic void setThemeName(String themeName)
setThemeName in interface HasThemethemeName - a space-separated string of theme names to set, or empty
string to remove all theme namespublic void setThemeName(String themeName, boolean set)
setThemeName in interface HasThemethemeName - the theme name to set or remove, not nullset - true to set the theme name, false to
remove itpublic void addThemeNames(String... themeNames)
addThemeNames in interface HasThemethemeNames - the theme name or theme names to be added to the componentpublic void removeThemeNames(String... themeNames)
removeThemeNames in interface HasThemethemeNames - the theme name or theme names to be removed from the componentpublic void setErrorMessage(String errorMessage)
setErrorMessage in interface HasValidationerrorMessage - a new error messagepublic String getErrorMessage()
getErrorMessage in interface HasValidationpublic void setInvalid(boolean invalid)
setInvalid in interface HasValidationinvalid - new value for component input validitypublic boolean isInvalid()
isInvalid in interface HasValidationprotected void validate()
public void setMin(LocalDateTime min)
min - the minimum date and time that is allowed to be set, or
null to remove any minimum constraintspublic LocalDateTime getMin()
null if there's no minimumpublic void setMax(LocalDateTime max)
max - the maximum date and time that is allowed to be set, or
null to remove any minimum constraintspublic LocalDateTime getMax()
null if there's no minimumpublic DatePicker.DatePickerI18n getDatePickerI18n()
DateTimePicker#setDatePickerI18n(DatePickerI18n)null, If the i18n
properties weren't set.public void setDatePickerI18n(DatePicker.DatePickerI18n i18n)
i18n - the internationalized properties, not nullpublic void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
setRequiredIndicatorVisible in interface HasValue<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>,LocalDateTime>setRequiredIndicatorVisible in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<DateTimePicker,LocalDateTime>,LocalDateTime>requiredIndicatorVisible - the value of the requiredIndicatorVisible to be setpublic void setAutoOpen(boolean autoOpen)
autoOpen - Value for the auto open property,public boolean isAutoOpen()
true if auto open is enabled. false otherwise. Default is trueprotected void onAttach(AttachEvent attachEvent)
ComponentThe default implementation does nothing.
This method is invoked before the AttachEvent is fired for the
component.
Copyright © 2021. All rights reserved.