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

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 92811b8f2d06c1471b1f17b0a9985bdaa1253a55
Author: jsorel <[email protected]>
AuthorDate: Wed Oct 21 16:59:46 2026 +0200

    fix(Shapefile): fix parsing empty dates
---
 .../main/org/apache/sis/storage/shapefile/dbf/DBFField.java | 13 +++++++++----
 .../sis/storage/shapefile/shp/ShapeGeometryEncoder.java     |  2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java
 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java
index 9896943a70..0a95a0476e 100644
--- 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java
+++ 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFField.java
@@ -255,10 +255,15 @@ public final class DBFField {
 
     private Object readDate(ChannelDataInput channel) throws IOException {
         final String str = new String(channel.readBytes(fieldLength)).trim();
-        final int year = Integer.parseUnsignedInt(str,0,4,10);
-        final int month = Integer.parseUnsignedInt(str,4,6,10);
-        final int day = Integer.parseUnsignedInt(str,6,8,10);
-        final var date = LocalDate.of(year, month, day);
+        final LocalDate date;
+        if (!str.equals("00000000")) {
+            final int year = Integer.parseUnsignedInt(str,0,4,10);
+            final int month = Integer.parseUnsignedInt(str,4,6,10);
+            final int day = Integer.parseUnsignedInt(str,6,8,10);
+            date = LocalDate.of(year, month, day);
+        } else {
+            date = LocalDate.of(0, 1, 1);
+        }
         if (timezone != null) {
             // Arbitrarily set the hours to the middle of the day.
             return ZonedDateTime.of(date, LocalTime.NOON, timezone);
diff --git 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
index 56f78b398f..81caa9f9f3 100644
--- 
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
+++ 
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/shp/ShapeGeometryEncoder.java
@@ -257,7 +257,7 @@ public abstract class ShapeGeometryEncoder<T extends 
Geometry> {
             if (nbOrdinates == 2) {
                 values = channel.readDoubles(nbValues * 2);
             } else {
-                values = channel.readDoubles(nbValues * nbOrdinates);
+                values = new double[nbValues * nbOrdinates];
                 for (int k = 0; k < nbValues; k++) {
                     values[k * nbOrdinates  ] = channel.readDouble();
                     values[k * nbOrdinates + 1] = channel.readDouble();

Reply via email to