Repository navigation
Parse common SIRI dateTime forms without DateTimeFormatter - #38
Merged
Merged
Conversation
vpaturet
force-pushed
the
feat/zdt-adapter-manual
branch
from
October 9, 2026 09:39
3daa66b to
aef7033
Compare
vpaturet
force-pushed
the
feat/zdt-adapter-manual
branch
from
October 9, 2026 09:46
aef7033 to
bc1c396
Compare
Add FastZonedDateTimeParser, a position-based parser for yyyy-MM-ddTHH:mm:ss[.fffffffff][Z|±HH:MM]. ZonedDateTimeAdapter tries it first and falls back to the previous ZonedDateTime.parse / LocalDateTime logic for any other form or out-of-range field, so results and exception types are unchanged. Local times without zone designator are resolved exactly as the fallback does.
vpaturet
force-pushed
the
feat/zdt-adapter-manual
branch
from
October 12, 2026 11:52
bc1c396 to
1c644fc
Compare
vpaturet
marked this pull request as ready for review
October 12, 2026 12:15
vpaturet
requested review from
lassetyr
and
a balanced review from Copilot
and removed request for
Copilot
October 12, 2026 12:20
Copilot stopped reviewing on behalf of
vpaturet due to an error
October 12, 2026 12:22
lassetyr
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
FastZonedDateTimeParser, a position-based parser foryyyy-MM-ddTHH:mm:ss[.fffffffff][Z|±HH:MM]. It reads the fields at fixed positions, uses no regular expressions and allocates nothing but the result.ZonedDateTimeAdapter.parsetries it first and falls back to the previousZonedDateTime.parse/LocalDateTime.parselogic for any other ISO form (missing seconds,±HH:MM:SSoffsets,[Region]suffixes, lowercaset/z, extended years, ...) and for any out-of-range field, so results and exception types are unchanged. Local times without zone designator are resolved in the fast path exactly as the fallback does (ZonedDateTime.ofLocalwith a UTC preferred offset).The same approach is in use in netex-java-model: entur/netex-java-model#310.
Results
Measured on a SIRI-ET document (282 MB, 1.8 million
xsd:dateTimevalues), JDK 25,-Duser.timezone=Europe/Oslo, JMH average time per parse:ZonedDateTimeAdapter.parsefor the whole dumpThe fast path handles 100 % of the values in that dump (95.7 % plain
±HH:MM, 4.3 % with a 1–9 digit fraction). A regex-based variant was also measured and only halved the cost, so it was dropped.End-to-end test
Full
SiriXml.parseXml(InputStream)of the 282 MB tst dump (18,874EstimatedVehicleJourney, 1.8 M dateTimes),-Duser.timezone=Europe/Oslo,-Xms6G -Xmx6G, 4 pinned cores, 5 interleaved JVM launches per arm × 5 measured parses after 3 warm-up:ZonedDateTimeAdapter.parsealone over the 1,795,022 real strings (5 JVMs per arm × 10 iterations): 906 ± 23 ns/op → 118 ± 10 ns/op (×7.7), consistent with the JMH figures in the description.The end-to-end gain (≈ 2.7 s) is about twice the adapter-only saving (1.8 M × 0.79 µs ≈ 1.4 s); the rest comes from the removed allocation pressure (fewer and shorter G1 pauses while the whole document tree is live) and the formatter running cold inside JAXB rather than hot in a micro loop. Per-round medians were consistent across all five rounds (master 6983–8127 ms, PR 4290–5745 ms).