The REST API uses the default date format yyyy-MM-dd'T'HH:mm:ss.SSSZ, whichrepresents a date with milliseconds and timezone information, e.g.,2016-01-25T13:33:42.165+0100.

Custom Date Format

A custom date format can be configured in the web.xmlfile of the REST API. To do so, the ServletContextListenerCustomJacksonDateFormatListener has to be added. The custom date formatcan be specified by the context parameterorg.camunda.bpm.engine.rest.jackson.dateFormat.

For example, if the date format should not contain milliseconds and timezoneinformation (yyyy-MM-dd'T'HH:mm:ss) the following configuration can beused.

To achieve this, you can edit the WEB-INF/web.xml file as follows:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  5. <!-- ... -->
  6. <listener>
  7. <listener-class>
  8. org.camunda.bpm.engine.rest.CustomJacksonDateFormatListener
  9. </listener-class>
  10. </listener>
  11. <context-param>
  12. <param-name>org.camunda.bpm.engine.rest.jackson.dateFormat</param-name>
  13. <param-value>yyyy-MM-dd'T'HH:mm:ss</param-value>
  14. </context-param>
  15. <!-- ... -->
  16. </web-app>

With this configuration the REST API will return dates with millisecondprecision and timezone information. Also, new dates with milliseconds and timezone informationcan be submitted to the REST API without losing these details.

Webapps compatibility

Be aware that, to be able to use the Camunda webapps, the date format must correspond to the following:

yyyy-MM-dd['T'HH:mm[:ss[.SSS[Z]]]]

原文: https://docs.camunda.org/manual/7.9/reference/rest/overview/date-format/