Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@JsonFormat overriden features don't apply when there are no other options while deserializing ZonedDateTime #196

Closed
MaciejDobrowolski opened this issue Jan 7, 2021 · 3 comments
Milestone

Comments

@MaciejDobrowolski
Copy link
Contributor

After deserializing a following class:

    static class WrapperWithFeatures {
        @JsonFormat(without = JsonFormat.Feature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
        public ZonedDateTime value;

        public WrapperWithFeatures() { }
        public WrapperWithFeatures(ZonedDateTime v) { value = v; }
    }

value field should preserve timezone from the source - but it doesn't. Following test fails:

    @Test
    public void testDeserializationWithZonePreserved() throws Throwable
    {
        WrapperWithFeatures wrapper = JsonMapper.builder()
                .addModule(new JavaTimeModule())
                .build()
                .readerFor(WrapperWithFeatures.class)
                .readValue("{\"value\":\"2000-01-01T12:00+01:00\"}");
        assertEquals("Timezone should be preserved.",
                ZonedDateTime.of(2000, 1, 1, 12, 0, 0 ,0, ZoneOffset.ofHours(1)),
                wrapper.value);
    }
@MaciejDobrowolski MaciejDobrowolski changed the title @JsonFormat overriden features don't apply when there are no other options @JsonFormat overriden features don't apply when there are no other options while deserializng ZonedDateTime Jan 7, 2021
MaciejDobrowolski added a commit to MaciejDobrowolski/jackson-modules-java8 that referenced this issue Jan 7, 2021
…eatures override if there were no other options defined on it
@cowtowncoder
Copy link
Member

And this is with 2.12.0 or an older version?

MaciejDobrowolski added a commit to MaciejDobrowolski/jackson-modules-java8 that referenced this issue Jan 8, 2021
…eatures override if there were no other options defined on it
@MaciejDobrowolski
Copy link
Contributor Author

MaciejDobrowolski commented Jan 8, 2021

This is for 2.12, but I believe it applies to all the previous versions as well

@cowtowncoder
Copy link
Member

Ok thanks, sounds good. Just wanted to know if it was a regression (new thing in 2.12) or was already there; makes sense it was already there.

cowtowncoder pushed a commit that referenced this issue Jan 8, 2021
…verride if there were no other options defined on it (#198)
@cowtowncoder cowtowncoder added this to the 2.12.1 milestone Jan 8, 2021
@cowtowncoder cowtowncoder changed the title @JsonFormat overriden features don't apply when there are no other options while deserializng ZonedDateTime @JsonFormat overriden features don't apply when there are no other options while deserializing ZonedDateTime Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants