This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch dev/1.1
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/dev/1.1 by this push:
new aa32e6e5 Fix the bug in parse date to int when year out of range (#500)
aa32e6e5 is described below
commit aa32e6e57b5d5ae8bc7f022eac022a57f6637897
Author: Haonan <[email protected]>
AuthorDate: Tue May 27 09:25:31 2025 +0800
Fix the bug in parse date to int when year out of range (#500)
Co-authored-by: FearfulTomcat27 <[email protected]>
---
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),