Visitar URL original
feat: add java.sql.Date converters (#1017) by Mikkey-f · Pull Request #1289 · apache/fesod · GitHub
Skip to content

feat: add java.sql.Date converters (#1017) - #1289

Open
Mikkey-f wants to merge 3 commits into
apache:mainfrom
Mikkey-f:feat/sqldate-converters
Open

Mikkey-f wants to merge 3 commits into
apache:mainfrom
Mikkey-f:feat/sqldate-converters

Conversation

@Mikkey-f

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

Copy link
Copy Markdown
Contributor

Purpose of the pull request

Related: #1017 (java.sql.Date slice). Proposal: #1017 (comment)

java.sql.Date is the last java.sql type without converters. Converters are keyed by the exact class, so a java.sql.Date field fails on read and write with Can not find 'Converter' support class Date, even though java.util.Date is supported. This mirrors java.sql.Time (#1092) and java.sql.Timestamp (#1220).

What's changed?

Added converters/sqldate and registered it in DefaultConverterLoader:

  • SqlDateNumberConverter (Excel NUMBER): reads through DateUtils.getLocalDate(serial, use1904windowing) → Date.valueOf(LocalDate), returning null for invalid serials; writes DateUtil.getExcelDate(value.toLocalDate(), use1904windowing).
  • SqlDateStringConverter (Excel STRING): parses/formats through LocalDate, honoring @DateTimeFormat and GlobalConfiguration.locale.
  • SqlDateDateConverter (write only, DATE cell): uses DateUtils.defaultLocalDateFormat unless @DateTimeFormat overrides it.

Registration matches the java.sql.Time / java.sql.Timestamp pattern; no existing behavior changes.

Verification

  • Red side (registrations removed): the XLSX/XLS/CSV round trip fails on all three formats with ExcelWriteDataConvertException: Can not find 'Converter' support class Date, and the loader registration test fails.
  • Green side: SqlDateConverterTest 10/10 and SqlDateRoundTripTest 3/3 (XLSX, XLS, CSV).
  • Full build mvn clean package -B -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 1,862 tests, 0 failures.
  • spotless:check and javadoc:javadoc pass.

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.

@psxjoy

psxjoy commented Nov 11, 2026

Copy link
Copy Markdown
Member

Thanks for the PR! One licensing detail before merge: the three SqlDate*Converter classes are adapted from EasyExcel's LocalDate*Converter counterparts. Per LEGAL-737 (see also #1322 / #1331), please add the following block right after the ASF license header in each file. Adjust the class name per file: LocalDateDateConverter, LocalDateStringConverter, LocalDateNumberConverter.

/*
 * Portions of this file are derived from Alibaba EasyExcel's LocalDateStringConverter.
 *
 * Copyright (C) 2018-2024 Alibaba Group Holding Ltd.
 */

No changes are needed to LICENSE or NOTICE.

@Mikkey-f

Copy link
Copy Markdown
Contributor Author

Thanks @psxjoy — added the attribution blocks in 63b1f43

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.

2 participants