Integration with JSON
Generally, the data which is received from the server is serialized in a JSON format.
The date
object in JSON is an ISO8601-formatted date string. For more details, refer to the documentation on the JSON.stringify
method. On the other hand, the DatePicker works only with JavaScript Date
instances.
To bind the DatePicker to dates which are serialized as strings, handle the parsing process:
- Convert the JSON date strings into valid JavaScript
Date
objects by using theIntlService
or any other suitableDate
parser. - Define the
value
property of the component. - Provide an
change
event handler to the DatePicker to get the selectedDate
value.
The following example demonstrates how to set the value of the DatePicker.