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

jackietien pushed a commit to branch iotdb
in repository https://gitbox.apache.org/repos/asf/tsfile.git


The following commit(s) were added to refs/heads/iotdb by this push:
     new 53d247f9 Fix the bug in parse date to int when year out of range
53d247f9 is described below

commit 53d247f9a40a554064a8db600c7ad64be01ba779
Author: FearfulTomcat27 <[email protected]>
AuthorDate: Wed Oct 9 21:16:23 2024 +0800

    Fix the bug in parse date to int when year out of range
---
 java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java 
b/java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java
index 2254f26b..cc7705cc 100644
--- a/java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java
+++ b/java/tsfile/src/main/java/org/apache/tsfile/utils/DateUtils.java
@@ -48,7 +48,7 @@ public class DateUtils {
       throw new DateTimeParseException(
           "Invalid date format. Please use YYYY-MM-DD format.", 
dateExpression, 0);
     }
-    if (date.getYear() < 1000) {
+    if (date.getYear() < 1000 || date.getYear() > 9999) {
       throw new DateTimeParseException("Year must be between 1000 and 9999.", 
dateExpression, 0);
     }
     return date.getYear() * 10000 + date.getMonthValue() * 100 + 
date.getDayOfMonth();
@@ -58,7 +58,7 @@ public class DateUtils {
     if (localDate == null) {
       throw new DateTimeParseException("Date expression is null or empty.", 
"", 0);
     }
-    if (localDate.getYear() < 1000) {
+    if (localDate.getYear() < 1000 || localDate.getYear() > 9999) {
       throw new DateTimeParseException(
           "Year must be between 1000 and 9999.", 
localDate.format(DATE_FORMATTER), 0);
     }

Reply via email to