feat: add java.sql.Timestamp converters - #1019
Open
SyedIshmumAhnaf wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class converter support for java.sql.Timestamp in fesod-sheet, aligning with the existing temporal converter family and registering the converters in the default loader alongside unit coverage.
Changes:
- Introduces
TimestampDateConverter,TimestampNumberConverter, andTimestampStringConverter. - Registers the new converters in
DefaultConverterLoaderfor read + default write behavior. - Adds
TimestampConverterTestto validate key registration and basic read/write conversions (number/string/date) including 1904 windowing.
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/test/java/org/apache/fesod/sheet/converter/TimestampConverterTest.java | Adds unit coverage for timestamp converters and default loader registration. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/timestamp/TimestampStringConverter.java | Implements Timestamp ↔ STRING conversion using DateUtils formatting/parsing. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/timestamp/TimestampNumberConverter.java | Implements Timestamp ↔ Excel numeric date conversion with 1904 windowing support. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/timestamp/TimestampDateConverter.java | Implements default write conversion to DATE with appropriate cell format. |
| fesod-sheet/src/main/java/org/apache/fesod/sheet/converters/DefaultConverterLoader.java | Wires the new timestamp converters into the default converter registry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+69
to
+79
| @Override | ||
| public WriteCellData<?> convertToExcelData( | ||
| Timestamp value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { | ||
| if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) { | ||
| return new WriteCellData<>( | ||
| BigDecimal.valueOf(DateUtil.getExcelDate(value, globalConfiguration.getUse1904windowing()))); | ||
| } else { | ||
| return new WriteCellData<>(BigDecimal.valueOf(DateUtil.getExcelDate( | ||
| value, contentProperty.getDateTimeFormatProperty().getUse1904windowing()))); | ||
| } | ||
| } |
| public WriteCellData<?> convertToExcelData( | ||
| Timestamp value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) | ||
| throws Exception { | ||
| WriteCellData<?> cellData = new WriteCellData<>(value); |
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
Add first-class converter support for
java.sql.Timestamp, following the existing temporal converter patterns in Apache Fesod.What's changed?
TimestampDateConverteras the default write converter forTimestamp.TimestampNumberConverterfor Excel numeric date conversion, includinguse1904windowinghandling.TimestampStringConverterusing the existingDateUtilsparsing/formatting behavior and@DateTimeFormatsupport.DefaultConverterLoaderusing the same read/write structure asLocalDateTime.TimestampConverterTestcovering:The change is intentionally scoped to
java.sql.Timestampand does not modify the converter lookup mechanism or other converter types.Verification:
./mvnw spotless:check./mvnw -pl fesod-sheet -Dmaven.test.skip=false -Dtest=TimestampConverterTest,ConverterTest,ConverterDataTest,CustomConverterTest testChecklist