@@ -106,10 +106,10 @@ public abstract class QueryParameterValue implements Serializable {
106106 .optionalEnd ()
107107 .toFormatter ()
108108 .withZone (ZoneOffset .UTC );
109- // Regex to identify >9 digits in the fraction part (e.g. .123456789123)
110- // Matches the dot, followed by 10-12 digits, followed by non-digits (like +00) or end of string
109+ // Regex to identify >9 digits in the fraction part (e.g. ` .123456789123` )
110+ // Matches the dot, followed by 10+ digits, followed by non-digits (like +00) or end of string
111111 private static final Pattern ISO8601_TIMESTAMP_HIGH_PRECISION_PATTERN =
112- Pattern .compile ("(\\ .\\ d{10,12 })(?:\\ D|$)" );
112+ Pattern .compile ("(\\ .\\ d{10,})(?:\\ D|$)" );
113113
114114 private static final DateTimeFormatter dateFormatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd" );
115115 private static final DateTimeFormatter timeFormatter =
@@ -556,6 +556,13 @@ static void validateTimestamp(String timestamp) {
556556 // Group 1 is the fractional part including the dot (e.g., ".123456789123")
557557 String fraction = matcher .group (1 );
558558
559+ // The fraction part includes the dot, so we check its length.
560+ // It should be at most 13 characters long (. + 12 digits).
561+ if (fraction .length () > 13 ) {
562+ throw new IllegalArgumentException (
563+ "Fractional portion of ISO8601 supports up to picosecond (12 digits)" );
564+ }
565+
559566 // Truncate to . + 9 digits
560567 String truncatedFraction = fraction .substring (0 , 10 );
561568 // Replace the entire fractional portion with the nanosecond portion. Digits exceeding the
@@ -566,12 +573,6 @@ static void validateTimestamp(String timestamp) {
566573 // It is valid as long as DateTimeFormatter doesn't throw an exception AND
567574 // the fractional portion past nanosecond precision is valid (up to picosecond)
568575 checkFormat (truncatedTimestamp , TIMESTAMP_VALIDATOR );
569- long value = Long .parseLong (fraction .substring (10 ));
570- // Picosecond supports the next three digits (0 - 999)
571- if (value >= 1000 ) {
572- throw new IllegalArgumentException (
573- "Fractional portion of ISO8601 supports up to picosecond (12 digits)" );
574- }
575576 return ;
576577 }
577578
0 commit comments