Skip to content

fix: support SQL date types in WriteCellData#912

Open
skytin1004 wants to merge 1 commit intoapache:mainfrom
skytin1004:fix/714-support-sql-date-types-write-cell-data
Open

fix: support SQL date types in WriteCellData#912
skytin1004 wants to merge 1 commit intoapache:mainfrom
skytin1004:fix/714-support-sql-date-types-write-cell-data

Conversation

@skytin1004
Copy link
Copy Markdown
Contributor

Purpose of the pull request

Closed: #714

I've fixed WriteCellData(Date) when the actual value is java.sql.Date or java.sql.Time.

I reproduced the failure locally and confirmed that both SQL date/time types can throw UnsupportedOperationException when toInstant() is called directly.

What's changed?

WriteCellData(Date) now uses an epoch-millis fallback only for java.sql.Date and java.sql.Time, because those types do not support toInstant().

The existing toInstant() path is kept for java.util.Date and java.sql.Timestamp. This keeps the behavior unchanged for regular date values and preserves java.sql.Timestamp nano precision.

I added regression tests for:

  • java.sql.Date
  • java.sql.Time
  • java.sql.Timestamp

To verify the fix, I first confirmed that the new WriteCellDataTest failed before the change with UnsupportedOperationException from java.sql.Date.toInstant() and java.sql.Time.toInstant(). After applying the fix, I confirmed that the new test passed, the existing related CellDataDataTest passed together with it, and the full fesod-sheet test suite also passed.

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.

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.

[Bug] WriteCellData 方法如果传入 java.sql.Date 会报错

1 participant