The `<tc:date/>` tag create an input field for a date or time. The date can also be edited in the textfield.

Tag Library Documentation: |

A date can have a label. To get a label use the `label` attribute.

<tc:date label="Date" value="\#{dateController.sputnikLd}"/>

The following date should be selected after reloading the page. This can be done with the attribute `focus`.

<tc:date label="Date (focus)" focus="true"/>>

It is NOT recommended to use `<f:convertDateTime>`, in most cases the converter will be configured automatically.

The `value` must be one of a set of several types. There are some new classes from since Java 8, which are generally preferred to use (there are several discussions in the net).

- (not recommended)
- for plain text (TBD)

Technical hint: Until Tobago 4 the user readable localized formatted String (e. g. 12/31/2050) was rendered into the HTML file and was post back to the server. Since Tobago 5 the string will be tranfered as ISO 8601 (e. g. 2050-12-31) to satisfy the HTML5 specification for input type="date", type="time" and type="datetime-local".

A date can be set as required with the `required` attribute. Such a date must contain a value, otherwise a submit is not possible. Leave the field blank and press 'submit' to see the error message.

<tc:date label="Date (required)" required="true" value="\#{dateController.once}">

A Java date can also be displayed in other components. Please use an appropriate converter.

<tc:in label="Date in Textfield" value="\#{dateController.today}"> <f:convertDateTime pattern="dd.MM.yyyy"/> </tc:in> <tc:textarea label="Date in Text Area" value="\#{dateController.today}"> <f:convertDateTime pattern="dd.MM.yyyy"/> </tc:textarea> <tc:out label="Date in Output" value="\#{dateController.today}"> <f:convertDateTime pattern="dd.MM.yyyy"/> </tc:out> <tc:label value="\#{dateController.today}"> <f:convertDateTime pattern="dd.MM.yyyy"/> </tc:label>

Styles can be set with the attributes `dateStyle` and `timeStyle`. Possible values are 'short', 'medium', 'long' and 'full'. It does not work with `<tc:date/>`, so here we use an output field.

To define the earliest or latest acceptable date, the attributes `min` and `max` can be used.

Press the button to submit the date to the server. The output field show the current value. The date can be changed with the datepicker or by entering a valid date in the textfield.

Using AJAX on change of date is currently problematic. In some cases, e.g. changing the last field, the change event will be fired (at the first key you've typed) and the cursor will lost it's position.

The output field in this example, display the given date. With `<f:ajax render="outputfield"/>`, the `<tc:out id="outputfield" .../>` will be rerendered, after the date changed. The date can be changed by button or by entering a valid date in the textfield. If the date is not valid, it won't be adopted.