Skip to content

Date

The Date form element is used for a date dialog.

Example

Example

Theme

Set this override the default alert dialog theme.

date(1) {
    theme = R.style.CustomDialogPicker
}

Value

  • You can set value directly by creating a new instance of FormPickerDateElement.DateHolder. However, dateValue and dateFormat will create the instance for you.
  • Call getTime() on value to get a Date object back.

Date Value

A java.util.Date value.

Date Format

A java.text.DateFormat value. By default this is SimpleDateFormat.getDateInstance(). It is advised to provide your own format.

Minimum Date

A java.util.Date value to set the minimum date for the Date picker.

Maximum Date

A java.util.Date value to set the maximum date for the Date picker.

Start Date

A java.util.Date to use if the date value is null. This will set the date picker to this date without showing a value on the form.

Example

Kotlin

date(1) {
    dateValue = Date()
    dateFormat = SimpleDateFormat("MM/dd/yyyy", Locale.US)
}

Java

List<BaseFormElement<?>> elements = new ArrayList<>();
FormPickerDateElement date = new FormPickerDateElement(1);
date.setDateValue(new Date());
date.setDateFormat(new SimpleDateFormat("MM/dd/yyyy", Locale.US));
elements.add(date);