feat: add ZonedDateTime converters - #1020
Open
alexsmolya wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class java.time.ZonedDateTime converter support to the fesod-sheet module, integrating it into the default converter registry and providing unit coverage to validate the expected zone/offset handling behavior.
Changes:
- Introduces ZonedDateTime converters for STRING, NUMBER, and DATE write scenarios.
- Registers the new converters in
DefaultConverterLoaderfor default read/write discovery. - Adds unit tests to validate conversion behavior and default registration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/DefaultConverterLoader.java | Registers ZonedDateTime converters in the default loader maps. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/zoneddatetime/ZonedDateTimeDateConverter.java | Adds DATE write converter (drops zone via toLocalDateTime() and applies data format). |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/zoneddatetime/ZonedDateTimeNumberConverter.java | Adds NUMBER read/write converter using Excel serial dates and ZoneId.systemDefault() on read. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/zoneddatetime/ZonedDateTimeStringConverter.java | Adds STRING read/write converter with ISO/custom pattern formatting and parsing fallback. |
| fesod-sheet/src/test/java/org/apache/fesod/sheet/converter/ZonedDateTimeConverterTest.java | Adds targeted tests for conversion semantics and loader registration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+37
to
+44
| import org.apache.fesod.sheet.metadata.GlobalConfiguration; | ||
| import org.apache.fesod.sheet.metadata.data.ReadCellData; | ||
| import org.apache.fesod.sheet.metadata.data.WriteCellData; | ||
| import org.apache.fesod.sheet.metadata.property.DateTimeFormatProperty; | ||
| import org.apache.fesod.sheet.metadata.property.ExcelContentProperty; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class ZonedDateTimeConverterTest { |
Comment on lines
+70
to
+77
| private DateTimeFormatter formatter(ExcelContentProperty contentProperty, Locale locale) { | ||
| if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) { | ||
| return DateTimeFormatter.ISO_ZONED_DATE_TIME; | ||
| } | ||
| return DateTimeFormatter.ofPattern( | ||
| contentProperty.getDateTimeFormatProperty().getFormat(), locale); | ||
| } | ||
| } |
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.
Purpose of the pull request
Related: #1017
What's changed?
Adds the approved
java.time.ZonedDateTimeconverter family and registers it with the default converter loader.toLocalDateTime(), intentionally dropping zone/offset while preserving local wall-clock fields.ZoneId.systemDefault().ZonedDateTimeConverterTestcoverage for supported directions, registration, formatting, and timezone-lossiness behavior.Checklist
Focused validation: 5 ZonedDateTime tests passed; Java 1.8-targeted compilation, Spotless, and
git diff --checkpassed.