Customizing datetime picker elements
By default all Date
properties will result in a DateTimeFormElement
which is rendered as a date time picker.
The form element can be customized through the DateTimeFormElementConfiguration
class.
The default configuration is determined based on the presence of @Temporal
annotations on the property.
The date picker supports 3 major modes: date, time and timestamp (date + time) with minutes being the maximum resolution.
The presence of @Past
and @Future
validation annotations will additionally restrict the dates that are selectable.
A specific date picker format can easily be specified by putting a DateTimeFormElementConfiguration.Format
attribute.
Advanced customization can be done by setting a complete DateTimeFormElementConfiguration
as attribute.
Dynamic configuration (for example setting the first selectable date relative to the current date) can only be done by specifying a DateTimeFormElementBuilder
manually and adding a custom post processor that modifies the DateTimeFormElementConfiguration
.
A DateTimeFormElementConfiguration
is always duplicated when creating an element so it is safe for post processors to modify the instance.
TemporalType.TIME
and JPAA property of type java.util.Date
but annotated with @Temporal(TemporalType.TIME)
will result in only time selection being available (hours and minutes).
However the @Temporal
annotation also influences how JPA will persist the data type.
If your type was created as a timestamp in the database schema, this might result in conversion errors.
With Hibernate you can resolve this by additionally specifying a @Type
annotation forcing the type to be persisted as timestamp.
@NotNull
@Column(name = "arrival_time")
@Temporal(TemporalType.TIME)
@Type( type = "timestamp")
private Date arrivalTime;