DateTime elements
A DateTimeFormElement
writes an <input>
element type="text" with the right classes to the output.
To represent a date/time picker it uses the Eonasdan datetimepicker JQuery plugin.
See DateTimeFormElementConfiguration
for configuration options.
Element and builder
The DateTimeFormElement
has an equivalent DateTimeFormElementBuilder
.
A builder can be created using BootstrapUiBuilders.datetime()
factory methods.
FileUploadFormElement attributes
Attribute | Description | Default |
---|---|---|
|
A Date, LocalDate, LocalTime, LocalDateTime or null value can be provided |
Null be default |
|
A |
Null be default |
|
Requires a |
Not set by default |
Examples
Simple datepicker
Given the following builder configuration
datetime()
.value( new Date() )
.build();
The following markup would be rendered:
<div data-bootstrapui-datetimepicker="{"format":"L LT","extraFormats":["YYYY-MM-DD HH:mm","L","YYYY-MM-DD"],"datepickerInput":"input[type=text]","locale":"nl-BE","exportFormat":"YYYY-MM-DD HH:mm"}" class="input-group js-form-datetimepicker date">
<input type="text" class="form-control" value="2018-12-05 16:12">
<span class="input-group-addon">
<span aria-hidden="true" class="glyphicon glyphicon-calendar"></span>
</span>
<input type="hidden" value="2018-12-05 16:12">
</div>
Localized fr_FR Date
Given the following builder configuration
DateTimeFormElementBuilder builder = datetime();
DateTimeFormElementConfiguration config = builder.getConfiguration();
config.setLocale( Locale.forLanguageTag( "fr-FR" ) );
config.setFormat( DateTimeFormElementConfiguration.Format.DATETIME_FULL );
config.setLocalizePatterns( false );
return builder
.configuration( config )
.value( LocalDateTime.now() )
.build();
The following markup would be rendered:
<div data-bootstrapui-datetimepicker="{"format":"LLL","extraFormats":["YYYY-MM-DD HH:mm","L","L LT","YYYY-MM-DD"],"datepickerInput":"input[type=text]","locale":"fr-FR","exportFormat":"YYYY-MM-DD HH:mm"}" class="input-group js-form-datetimepicker date">
<input type="text" class="form-control" value="2018-12-05 16:12">
<span class="input-group-addon">
<span aria-hidden="true" class="glyphicon glyphicon-calendar"></span>
</span>
<input type="hidden" value="2018-12-05 16:12">
</div>