This is an automated email from the ASF dual-hosted git repository.

delei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fesod.git


The following commit(s) were added to refs/heads/main by this push:
     new 6374a8ce fix: support SQL date types in WriteCellData (#912)
6374a8ce is described below

commit 6374a8ceb67dd08dbce8980fa17bdf5f3453d875
Author: Minseok Song <[email protected]>
AuthorDate: Tue Jun 23 13:41:24 2026 +0900

    fix: support SQL date types in WriteCellData (#912)
    
    * fix: support SQL date types in WriteCellData
    
    * fix: avoid timezone fallback for SQL date types
    
    ---------
    
    Co-authored-by: DeleiGuo <[email protected]>
---
 .../fesod/sheet/metadata/data/WriteCellData.java   |  8 +++-
 .../sheet/metadata/data/WriteCellDataTest.java     | 56 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git 
a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/data/WriteCellData.java
 
b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/data/WriteCellData.java
index cf351136..0985423f 100644
--- 
a/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/data/WriteCellData.java
+++ 
b/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/data/WriteCellData.java
@@ -169,7 +169,13 @@ public class WriteCellData<T> extends CellData<T> {
             throw new IllegalArgumentException("DateValue can not be null");
         }
         setType(CellDataTypeEnum.DATE);
-        this.dateValue = LocalDateTime.ofInstant(dateValue.toInstant(), 
ZoneId.systemDefault());
+        if (dateValue instanceof java.sql.Date) {
+            this.dateValue = ((java.sql.Date) 
dateValue).toLocalDate().atStartOfDay();
+        } else if (dateValue instanceof java.sql.Time) {
+            this.dateValue = ((java.sql.Time) 
dateValue).toLocalTime().atDate(java.time.LocalDate.of(1970, 1, 1));
+        } else {
+            this.dateValue = LocalDateTime.ofInstant(dateValue.toInstant(), 
ZoneId.systemDefault());
+        }
     }
 
     /**
diff --git 
a/fesod-sheet/src/test/java/org/apache/fesod/sheet/metadata/data/WriteCellDataTest.java
 
b/fesod-sheet/src/test/java/org/apache/fesod/sheet/metadata/data/WriteCellDataTest.java
new file mode 100644
index 00000000..11831805
--- /dev/null
+++ 
b/fesod-sheet/src/test/java/org/apache/fesod/sheet/metadata/data/WriteCellDataTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.fesod.sheet.metadata.data;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import org.apache.fesod.sheet.enums.CellDataTypeEnum;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class WriteCellDataTest {
+
+    @Test
+    void constructorShouldSupportSqlDate() {
+        WriteCellData<?> cellData = new 
WriteCellData<>(java.sql.Date.valueOf("2026-05-07"));
+
+        Assertions.assertEquals(CellDataTypeEnum.DATE, cellData.getType());
+        Assertions.assertEquals(
+                LocalDate.of(2026, 5, 7), 
cellData.getDateValue().toLocalDate());
+    }
+
+    @Test
+    void constructorShouldSupportSqlTime() {
+        WriteCellData<?> cellData = new 
WriteCellData<>(java.sql.Time.valueOf("12:34:56"));
+
+        Assertions.assertEquals(CellDataTypeEnum.DATE, cellData.getType());
+        Assertions.assertEquals(
+                LocalTime.of(12, 34, 56), 
cellData.getDateValue().toLocalTime());
+    }
+
+    @Test
+    void constructorShouldKeepSupportingSqlTimestampNanos() {
+        WriteCellData<?> cellData = new 
WriteCellData<>(java.sql.Timestamp.valueOf("2026-05-07 12:34:56.789123456"));
+
+        Assertions.assertEquals(CellDataTypeEnum.DATE, cellData.getType());
+        Assertions.assertEquals(LocalDateTime.of(2026, 5, 7, 12, 34, 56, 
789_123_456), cellData.getDateValue());
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to