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 TimePicker works only with JavaScript Date instances.

To bind the TimePicker to dates which are serialized as strings, handle the parsing process:

  1. Convert the JSON date strings into valid JavaScript Date objects by using the IntlService or any other suitable Date parser.
  2. Define the value property of the component.
  3. Provide an onChange event handler to the TimePicker to get the selected Date value.

The following example demonstrates how to set the value of the TimePicker.

Example
View Source
Change Theme:

In this article

Not finding the help you need?