The Date Picker is a Screen Component that renders an input field for choosing a date. It provides a popup with a calendar to pick a date from and makes it easy for the user to enter the right value.

The Date Picker automatically handles the specific rendering for small screens on touch devices. For the Date Picker to change to this mode, the following conditions need to be fulfilled:
- A Viewport Screen component is rendered on the screen.
- The device has to be a touch device.
- The width or height of the Viewport has to be smaller than 550px.
For more information on Viewports see: Screen Components: Viewport.



The following properties are available for the Date Picker:
- Binding – The binding is the date object to be displayed and written back to the model.
- Earliest Selectable Date – The user will not be able to set a date that is earlier than this date. An extra validator is not necessary; the component will automatically validate this setting.
The expression of this property can return an object of the following types:
- Date
- String of the format
yyyy-mm-dd (for example, '2000-01-21') - String with values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days). Example:
-1y-1m will take the current date as the base and subtract 1 year and 1 month. The resulting date will be used as the earliest selectable date.
- Latest Selectable Date – The user will not be able to set a date that is later than this date. An extra validator is not necessary; the component will automatically validate this setting.
The expression of this property can return an object of the following types:
- Date
- String of the format
yyyy-mm-dd (for example, '2000-01-21') - String with values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days). Example:
+1y+1m will take the current date as the base and add 1 year and 1 month. The resulting date will be used as the latest selectable date.
- Show As Text If Disabled – As soon as the Date Picker is disabled, it is rendered as a simple text element instead of as a disabled input element.
The Date Picker uses the Format Pattern Service and thus the Format Pattern Business Objects of Appway to display and parse values for the Date Picker.
It is not possible to set an individual format on a Date Picker. This is to avoid inconsistent date formatting within a solution. The actual Format Pattern is selected automatically based on the current translation language. Appway makes a distinction between formatting Date Input and Date Output.
Output Format Patterns are used when a page is rendered and a variable of type Date is displayed, as is the case with the Date Picker.

Output Format Patterns can be classified into two types:
- Format – for example, "short", "medium", or "long". The format is mandatory. It is also possible to have solution-specific or component-specific formats like "portal".
- Locale – for example, "en", "de", or "de_CH". The locale is optional. If it is not set, the pattern is treated as default pattern for the given format.
The Date Picker Screen Component only works with date output patterns for format "short". Date output patterns with other formats like "medium" or "long" are ignored.
At runtime, the selection of the applied Output Format Pattern works as follows:
- The current translation language (locale) is detected. See support document Language Priority for more information.
- Appway checks if there is an Output Format Pattern for the detected locale with format "short". If one is found, it is applied.
- If no Output Format Pattern is found, the locale is shortened if possible (for example, "en_US" to "en"). Step 2 is then repeated.
- If the locale cannot be shortened anymore, Appway checks if there is a default Output Format Pattern (locale not set) with format "short".
- If there is no default Output Format Pattern, the Date Format API built into Java is used to format the date.
Note: In order to be in full control of the date output pattern (and not depend on any language settings), all date output patterns with format "short", except for the default date output pattern (it usually has the ID "DateOutDefaultShort"), can be deleted and committed. This will force the Date Picker to always use the pattern defined by this remaining Business Object.
Input Format Patterns are used when a form is submitted to the server. The Date Picker uses the Format Pattern Service which parses the specified date against the available Date Input Format Patterns.

The sequence defines which pattern Appway tries to match. It starts with the first item in the sequence and if the format of the input does not match, it continues to the next until it finds a matching format. If none of the patterns match, then a validation error is displayed. The text of the validation message can be modified with the label validation.error.date.
It is possible to override the built-in way Format Patterns are resolved (described in the previous chapters) with your own logic.
To do so, define an Appway Script Function and reference it in the 'datepicker2.localeFunctionId' configuration property of the Component Extension. The referenced Script Function must return a string representation of a valid locale (e.g. "en", "en_US", "de_DE").
Using the return value, Appway searches the corresponding Date Output Pattern of the format "short". If such a Format Pattern is found, it is used for rendering the Date Picker as well as parsing the entered date.
If no Appway Script Function is referenced, or if the function returns a locale for which no Date Output Pattern of the format "short" exists, Appway falls back to its built-in way of resolving patterns.
- Title [aw.DatePicker.mobile.popup.title]: header (only for the mobile version).
The Base Package (Solution Design > [Base Package] > Business Objects) contains a series of Label Business Objects that can be used to localize the Date Picker interface, as shown in the image below:

In order to enter and edit these labels, follow the procedure outlined in the Language and Labels article.
Label Business Objects need to be committed to be used.
The Date Picker Style Business Object has four states:
- Focused
- Disabled
- ReadOnly
- Error
These are the properties that allow customizing the component:
-
Calendar icon: allows customizing the color and outer spacing of the icon that opens the date selector popup.
-
Size: defines the minimum and maximum dimensions of the Date Picker component.
-
Outer Spacing: defines the space between the Date Picker component and the border.
-
Text Input (virtual): refers to a Text Input (virtual) Style Business Object to define style of the date displayed on the Date Picker component.
-
Error Box (virtual): refers to an ErrorBox (virtual) Style Business Object to define the style of the Date Picker component and error message when in Error state.
-
Popup (virtual): refers to a Popup (virtual) Style Business Object to define the style of the date selector popup.
-
For more information on Style Business Object styling properties, see the Style Business Object: Styling Properties section.
-
For more information on Virtual Components, see the Style Business Objects Referencing Virtual Components section and the Virtual Style Business Objects article.
For design suggestions, see the Text Fields section of design.appway.com.