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 <[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 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),
