Why json-patch changing the Date format

209 Views Asked by At

I am using json patch 1.13 version to apply patch on my json payload .

This is the POM Entry using for json patch

<dependency>
  <groupId>com.github.java-json-tools</groupId>
  <artifactId>json-patch</artifactId>
  <version>1.13</version>
</dependency>

The existing payload have value like

{
 "expirationDate": "2022-05-15T01:59:59"
}

I am applying the patch with below patch operation, . This is to update the value with new date .

[
{
    "op": "replace",
    "path": "/expirationDate",
    "value": "2023-05-15T02:59:59"
}
]

But after applying the patch the new object have differently formatted Date value like

Java code
JsonNode patched = patch.apply(objectMapper.convertValue(targetCustomer, JsonNode.class));
return objectMapper.treeToValue(patched, Customer.class);

Output
expirationDate=Mon May 15 01:59:59 EDT 2023

Expected Output
expirationDate: "2023-05-15T01:59:59"

Any reason its changing the format or how i can fix this.
0

There are 0 best solutions below