`ZonedDateTime` loses information about zone id (Default Value Change for 4.x?)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
Research direction
The issue includes a JUnit reproduction using JsonMapper and ZonedDateTime; start by locating the Java time serializers and deserializers in the repository and their existing tests. Run the relevant tests, then add coverage for preserving the Europe/Berlin zone id during JSON writing and parsing. Done means the reproduced round trip and expected JSON assertions pass.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
The following tests all fail with jackson 3.1.8 and 3.2.4.
Writing JSON omits the ZoneId from the output.
Parsing JSON normalizes the ZoneId to UTC.
Both is wrong since the ZoneId is the entire difference between ZonedDateTime and OffsetDateTime and must not get lost.
Version Information
jackson 3.1.8 and 3.2.4
Reproduction
import org.junit.jupiter.api.Test;
import tools.jackson.databind.json.JsonMapper;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
class JacksonTest {
private static final JsonMapper JSON_MAPPER =
JsonMapper.builder()
.build();
private static final ZonedDateTime ZONED_DATE_TIME = ZonedDateTime.of(
2026, 10, 29,
13, 12, 0, 666161,
ZoneId.of("Europe/Berlin")
);
private static final Example EXAMPLE_INSTANCE = new Example(ZONED_DATE_TIME);
private static final String EXPECTED_JSON_STRING =
"{\"zonedDateTime\":\"2026-10-29T13:12:00.000666161+01:00[Europe/Berlin]\"}";
@Test
void creatingAndParsingJsonWorks() {
String jsonString = JSON_MAPPER.writeValueAsString(EXAMPLE_INSTANCE);
Example result = JSON_MAPPER.readValue(jsonString, Example.class);
assertEquals(EXAMPLE_INSTANCE, result);
}
@Test
void creatingJsonWorks() {
String jsonString = JSON_MAPPER.writeValueAsString(EXAMPLE_INSTANCE);
assertEquals(
EXPECTED_JSON_STRING,
jsonString
);
}
@Test
void parsingJsonWorks() {
Example parsed = JSON_MAPPER.readValue(
EXPECTED_JSON_STRING,
Example.class);
assertEquals(
EXAMPLE_INSTANCE,
parsed
);
}
public static final class Example {
private ZonedDateTime zonedDateTime;
public Example() {
this(null);
}
public Example(ZonedDateTime zonedDateTime) {
this.zonedDateTime = zonedDateTime;
}
public ZonedDateTime getZonedDateTime() {
return zonedDateTime;
}
public void setZonedDateTime(ZonedDateTime zonedDateTime) {
this.zonedDateTime = zonedDateTime;
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
Example example = (Example) o;
return Objects.equals(zonedDateTime, example.zonedDateTime);
}
@Override
public int hashCode() {
return Objects.hashCode(zonedDateTime);
}
@Override
public String toString() {
return "Example{" +
"zonedDateTime=" + zonedDateTime +
'}';
}
}
}
Expected behavior
All tests should be green.
- Dominant language
- Java
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 59
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/jackson-databind
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FasterXML/jackson-databind#6443 ·
Maintainers usually reply within 1 day
-
to-evaluate
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
FasterXML/jackson-databind#6340 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 12/100
FasterXML/jackson-databind#6442 ·
Maintainers usually reply within 1 day
-
`@JsonUnwrapped` value with `EXTERNAL_PROPERTY` type id silently deserialized as `null` (or misleading unknown-property error)Possibly taken @wn1331 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
FasterXML/jackson-databind#6421 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 35/100
FasterXML/jackson-databind#6418 · 2 comments ·
Maintainers usually reply within 1 day
All issues in FasterXML/jackson-databind
Similar issues
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPossibly taken @Rishankgupta08 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seleniumboot/selenium-boot#258 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day