You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tsfile.apache.org by ha...@apache.org on 2025/05/26 04:25:20 UTC

(tsfile) branch cp_illegal_date created (now 081fec94)

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

haonan pushed a change to branch cp_illegal_date
in repository https://gitbox.apache.org/repos/asf/tsfile.git


      at 081fec94 Fix the bug in parse date to int when year out of range

This branch includes the following new commits:

     new 081fec94 Fix the bug in parse date to int when year out of range

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(tsfile) 01/01: Fix the bug in parse date to int when year out of range

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 081fec944c926e0ef307e94960ed9c8fd3a78d80
Author: FearfulTomcat27 <14...@qq.com>
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 474aca5f..dc531baa 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(DateTimeFormatter.ISO_LOCAL_DATE),