[FLINK-39995][json] Add ISO-8601 timestamp format with explicit timezone offset support#28546
[FLINK-39995][json] Add ISO-8601 timestamp format with explicit timezone offset support#28546ddebowczyk92 wants to merge 1 commit into
Conversation
24e3845 to
f5b83f2
Compare
…one offset support
f5b83f2 to
ce32d20
Compare
|
The new format parses explicit offsets, but serialization currently emits the resulting instant with |
| * Formatter for ISO8601 string representation of a timestamp value (with explicit timezone | ||
| * offset). | ||
| */ | ||
| public static final DateTimeFormatter ISO8601_TIMESTAMP_WITH_OFFSET_FORMAT = |
There was a problem hiding this comment.
Please could you update the docs around this change.
| case ISO_8601: | ||
| parsedTimestamp = ISO8601_TIMESTAMP_FORMAT.parse(jp.getText()); | ||
| break; | ||
| case ISO_8601_WITH_OFFSET: |
There was a problem hiding this comment.
my AI says
For DST: Document that this format preserves the explicit offset only, not the timezone. Users needing DST-aware handling should use TIMESTAMP_WITH_LOCAL_TIMEZONE with a proper timezone ID (e.g., America/New_York), not just offsets.
For Half-Hour Timezones: Add comprehensive tests:
root.put("timestamp_india", "1990-10-14T12:12:43.123+05:30");
root.put("timestamp_nepal", "1990-10-14T12:12:43.123+05:45");
Consider: Whether output should preserve the original offset instead of always converting to UTC. Current behavior may surprise users expecting offset preservation.
Documentation: Clearly state that this format converts all timestamps to UTC offset (+00:00) on output, regardless of input offset.
What is the purpose of the change
The current
ISO-8601timestamp format option forJSONis misleading as it does not support timestamps with explicit timezone offsets (e.g.,2026-06-25T09:15:00+00:00).The existing
ISO-8601format only handles timestamps with UTC 'Z' suffix:yyyy-MM-ddTHH:mm:ss.s{precision}ZIt cannot parse valid
ISO-8601timestamps with explicit timezone offsets like+02:00,-05:00, etc.This change adds a new timestamp format option
ISO-8601-WITH-OFFSETthat properlyhandles timestamps with explicit timezone offsets in the format:
yyyy-MM-ddTHH:mm:ss.s{precision}±HH:mmBrief change log
TimestampFormat.ISO_8601_WITH_OFFSETenum valueISO8601_TIMESTAMP_WITH_OFFSET_FORMATDateTimeFormatterISO-8601-WITH-OFFSETVerifying this change
Added unit tests covering various offset formats and precisions
Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?