Software AG Products 10.7 | Administering Integration Server | Controlling JSON Output | Controlling Date Encoding in JSON Responses
 
Controlling Date Encoding in JSON Responses
Because JSON does not define a date data type, Integration Server includes the uses the watt.server.json.encodeDateAs server configuration to determine how instances of java.util.Date are encoded in a response. If the pipeline for the response include a date object that is an instance of java.util.Date, Integration Server uses the value of the server configuration parameter to determine how the date object is encoded.
A request to Integration Server can include a query parameter to specify the encoding for dates in the JSON response. The jsonDateEncoding query parameter in the request URL overrides the value of the watt.server.json.encodeDateAs server configuration parameter. If a date object that is an instance of java.util.Date exists in the pipeline that will be used for the response, the value of the jsonDateEncoding query parameter in the request URL instructs Integration Server how to encode the jva.util.date fields in the response.
The jsonDateEncoding query parameter can be set to one of the following:
*Null to encode instances of java.util.Date using the following pattern: EEE MMM dd HH:mm:ss zzz yyyy
*long to encode java.util.Data instances as timestamps, specifically the number of milliseconds since Jan 1, 1970 00:00:00. The dates are encoded as JSON numbers.
*ISO8601 to encode java.utilData instances in a standard ISO format of: YYYY-MM-DD'T'HH:mm:ss.sssZ. The dates are encoded JSON Strings.
*Custom format in which dates are encoded in the supplied pattern. The pattern must adhere to the date and time patterns as described in the java.text.SimpleDateFormat class in the Oracle Java API documentation. The dates are encoded as JSON Strings.
This query parameter works with the following directives: admin, invoke, rest, and restv2.
Example: GET /invoke/pub.date/getCurrentDate?jsonDateEncoding=YYYY/MM/DD%20HH:mm:ss
Integration Server uses this query parameter only if Content-type: Application/json is added in the header.