It seems really hard to achieve a reliable matcher for values of types like OffsetDateTime with jsonPath.

If I have something like:

DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
OffsetDateTime start = OffsetDateTime.now();
mvc.perform(
        ...)
        .andExpect(jsonPath("$.start", is(start.format(pattern))))

It will fail sometimes like this:

java.lang.AssertionError: JSON path "$.start"
Expected: is  "2023-08-02T22:24:35.350-04:00"
     but: was "2023-08-02T22:24:35.35-04:00"

Now I know the above is more a problem on the DateTimeFormatter itself, but it is a constant battle to try matching DateTime values with the jsonPath, since it is hard-coded into JsonPathExpectationsHelper without any possibility of configuration.

Comment From: sbrannen

@eduardolbueno, have you tried the hamcrest-date extensions for Hamcrest?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.