Skip to content

feat: add java.sql.Timestamp converters - #1019

Open
SyedIshmumAhnaf wants to merge 3 commits into
apache:mainfrom
SyedIshmumAhnaf:feat/timestamp-converters
Open

SyedIshmumAhnaf wants to merge 3 commits into
apache:mainfrom
SyedIshmumAhnaf:feat/timestamp-converters

Conversation

@SyedIshmumAhnaf

Copy link
Copy Markdown

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?

  • Added TimestampDateConverter as the default write converter for Timestamp.
  • Added TimestampNumberConverter for Excel numeric date conversion, including use1904windowing handling.
  • Added TimestampStringConverter using the existing DateUtils parsing/formatting behavior and @DateTimeFormat support.
  • Registered the new converters in DefaultConverterLoader using the same read/write structure as LocalDateTime.
  • Added TimestampConverterTest covering:
    • converter support keys
    • number read/write behavior
    • 1904 date windowing
    • string parsing/formatting
    • custom date-time format handling
    • date write behavior
    • default converter registration

The change is intentionally scoped to java.sql.Timestamp and 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 test
    • 68 tests passed
  • CI-equivalent module build with tests enabled passed successfully.

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.

@delei delei added the PR: first-time contributor first-time contributor label Aug 18, 2026
@delei
delei requested a lite review from Copilot August 18, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and TimestampStringConverter.
  • Registers the new converters in DefaultConverterLoader for read + default write behavior.
  • Adds TimestampConverterTest to 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);
contentProperty.setDateTimeFormatProperty(dateTimeFormatProperty);

GlobalConfiguration globalConfiguration = new GlobalConfiguration();
globalConfiguration.setLocale(Locale.US);

@nkuprins nkuprins Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test still passes even if you remove the 129 line or replace it with Locale.JAPANESE or new Locale("th", "TH").

To actually check the locale, consider using a different format.
For example, "dd MMMM yyyy HH:mm:ss"="01 January 2020 01:01:01",
which now fails for Locale.GERMAN etc.

@SyedIshmumAhnaf

Copy link
Copy Markdown
Author

Updated the test to use a locale-sensitive MMMM format with Locale.US, including January for both parsing and formatting. Thanks for catching that.

@bengbengbalabalabeng

bengbengbalabalabeng commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

The newly added files in this PR are implemented from scratch and are not derived from Alibaba's EasyExcel. Therefore, no EasyExcel-related license header is required for these files.

Please refer to: https://github.com/apache/fesod/blob/main/fesod-sheet/src/main/java/org/apache/fesod/sheet/FesodSheet.java

@nkuprins

Copy link
Copy Markdown
Contributor

Please resolve the conflicts from main

@bengbengbalabalabeng bengbengbalabalabeng added the waiting for feedback Waiting for a reply or feedback label Sep 18, 2026
@Mikkey-f

Copy link
Copy Markdown
Contributor

Hi @SyedIshmumAhnaf — checking in on this one. nkuprins asked for a rebase a month ago and it has been quiet since, so I wanted to ask before assuming anything.

Are you still planning to carry it forward? If you don't have the bandwidth for it right now, I'd be happy to pick it up — I'd rebase the three converters on current main, keep the implementation and tests, adjust to the current testkit conventions where needed, and reference this PR and #1017 in the description so your work stays credited. Either way, just let me know.

@SyedIshmumAhnaf

Copy link
Copy Markdown
Author

Hi @Mikkey-f, sorry for being awol. I've been dealing with some things lately which has kept me off from GitHub and contributing. I hope to get back soon to the picture however I would be more than happy for you to continue working on this. Primarily because I am still working some things out and not sure of the timeline by when I might get my hands on this. If you have any questions regarding the existing work, please feel free to tag me and I'll try my very best to respond at the earliest.

@Mikkey-f

Copy link
Copy Markdown
Contributor

Hi @SyedIshmumAhnaf — thanks for the kind words and for handing this over, and no worries at all; these things take the time they take. I'll carry this forward from here.

So you know what to expect: your commits will come along with your authorship preserved, brought up to date with main. As part of the carry-forward I'll address @nkuprins's locale-test point and the two Copilot notes, then open a fresh PR linked to #1017 that credits you as the original author and supersedes #1019. If a question comes up about the existing implementation I'll tag you here, and you're welcome to take a look at the carried-forward PR whenever you're back.

Nothing needed from you in the meantime — take care of things on your side first.

@Mikkey-f

Copy link
Copy Markdown
Contributor

Carried forward as #1220 — your commits are preserved with your authorship, plus one adaptation commit to bring them up to date with main (details in the PR description). Thanks again for the hand-off!

Mikkey-f added a commit to Mikkey-f/fesod that referenced this pull request Oct 15, 2026
Carry-forward of apache#1019 (original implementation by Syed Ishmum Ahnaf):

- Resolve the 1904 windowing flag through the shared DateUtils.isDate1904
  helper, like the rest of the date converter family. Reading
  DateTimeFormatProperty#getUse1904windowing() directly broke on the null
  DEFAULT preserved by apache#1042 and threw a NullPointerException whenever
  @DateTimeFormat was present without an explicit use1904windowing value.
- Drop the EasyExcel derived license header from the four new files; they
  are written from scratch, so the plain ASF header applies.
- Align with current conventions: Class<?> supportJavaTypeKey, single-line
  javadoc, and tests moved to the mirrored converters.timestamp package
  with qualified assertions, the thread-local cache teardown used by the
  sibling suites, a loader family test and an XLSX/XLS/CSV round trip.

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

PR: first-time contributor first-time contributor waiting for feedback Waiting for a reply or feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants