Skip to content

feat: add OffsetTime string converter (#1017) - #1315

Open
Mikkey-f wants to merge 1 commit into
apache:mainfrom
Mikkey-f:feat/1017-offsettime-converter
Open

Mikkey-f wants to merge 1 commit into
apache:mainfrom
Mikkey-f:feat/1017-offsettime-converter

Conversation

@Mikkey-f

@Mikkey-f Mikkey-f commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Purpose of the pull request

Related: #1017

Adds a built-in converter for java.time.OffsetTime, the last JDK 8 java.time type without one. On current main a POJO field of this type fails on read and write with Can not find 'Converter' support class OffsetTime.

Scope follows the proposal posted in #1017 (string only, no objections raised in #1017): Excel NUMBER/DATE cells store a wall-clock time without an offset, so a numeric path would have to fabricate one.

What's changed?

  • New converters/offsettime/OffsetTimeStringConverter, mirroring OffsetDateTimeStringConverter: default format ISO_OFFSET_TIME, @DateTimeFormat patterns honored, locale-aware through DateUtils.
  • New DateUtils.parseOffsetTime(...) / DateUtils.format(OffsetTime, ...) helpers, same shape as the existing OffsetDateTime ones. Empty/null format falls back to ISO_OFFSET_TIME; text without an offset is rejected rather than defaulted.
  • Registered with putAllConverter (read), putWriteConverter (XLSX/XLS write) and putWriteStringConverter (CSV). The proposal mentioned the first and third; putWriteConverter is also needed because a non-CSV write resolves the converter key without a cell type — the same registration used by UUIDStringConverter and InstantStringConverter.
  • Tests: converter unit tests (keys, ISO/custom format, empty/null pattern, locale, missing/invalid offset, registration), DateUtils helper tests, and an XLSX/XLS/CSV round trip covering both the default ISO format and a @DateTimeFormat pattern.

Verification

  • ./mvnw spotless:check passes.
  • ./mvnw clean package -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 1,895 tests, 0 failures.
  • ./mvnw javadoc:javadoc passes.
  • Red side: without the registrations the three round-trip cases fail with Can not find 'Converter' support class OffsetTime, and the registration test fails on a null converter.

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant