Date Fragment
In This Topic
Date Formats
All internal handling of dates in Interactive Forms follows the ISO-8601 format (see the ISO website and this Wikipedia article for detailed information on the ISO specification). This means all internal representations of a date in Interactive Forms are of the format yyyy-MM-dd. Dates are represented by the nl.gx.forms.wmpformapi.engine.FormDate
class. This class stores both the ISO representation as well as the locale of the form that the date was submitted in. When using the value of the date fragment, the local representation of the date is returned by default. For example, if you enter the ISO date 2021-07-30 in a Dutch form, then the visible representation will be 30-07-2021 (the Dutch date format). You can also access the ISO format of the entered date if desired.
Date Picker (HTML5)
The default XperienCentral presentation uses the HTML5 date picker for entering dates in Interactive Forms. The format for entering the date in the HTML5 element is browser-dependent, however, the date is always submitted to the backend in ISO format.
Accessing the Contents of a Date Fragment
There are two representations of a Date Fragment.
Local Format (Default)
This format is defined by the locale of the form and uses the java.time
API to format dates to their appropriate local formats.
This format is accessed by default and is constructed via the FormDate#toString()
method. In JavaScript and JSP, this format is accessed by default when calling the value
attribute of a fragment. For example:
$step1.mydatefragment.value$
ISO Format
This format is defined by ISO-8601 in order to unambiguously represent dates. To access this format, the nl.gx.forms.wmpformapi.engine.FormDate#getIsoFormat()
method is available which is called using .isoFormat
in JSP and (server-side) JavaScript. The following example retrieves the ISO format of a Date fragment:
$step1.mydatefragment.value.isoFormat$
Prefilling
Prefilling input of a Date fragment needs to be supplied in the ISO format.
Date Validator
The date validator validates dates based on their ISO representation. It does so by checking whether the date representation is a FormDate
object (backend) or not (frontend). If it is, it accesses FormDate#getIsoFormat()
. If not, the string is already assumed to be in ISO format.
Backwards Compatibility
Dates for the Dutch locale are hard-coded to dd-MM-yyyy because version R33 and earlier of XperienCentral used this format for the representation of dates in the front-end. GX Software strongly recommends that you use the ISO-8601 format for the internal representation and code for dates in Interactive Forms.