Skip to content

Commit

Permalink
Update pattern regex, and use the deprecation logger
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop committed Sep 16, 2024
1 parent 6975e85 commit eb4dc9a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.core.Predicates;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.logging.LogManager;

import java.time.Clock;
import java.time.Duration;
Expand Down Expand Up @@ -391,13 +390,17 @@ public static ZonedDateTime nowWithMillisResolution(Clock clock) {

// check for all textual fields, and localized zone offset
private static final Predicate<String> CONTAINS_CHANGING_TEXT_SPECIFIERS = System.getProperty("java.locale.providers", "")
.contains("COMPAT") ? Pattern.compile("[EcGaO]|MMM|LLL|eee|ccc|QQQ|ZZZZ").asPredicate() : Predicates.never();
.contains("COMPAT") ? Pattern.compile("[BEGOavz]|LLL|MMM|QQQ|ccc|eee|ZZZZ").asPredicate() : Predicates.never();

@UpdateForV9 // this can be removed, we will only use CLDR on v9
static void checkTextualDateFormats(String format) {
if (CONTAINS_CHANGING_TEXT_SPECIFIERS.test(format)) {
LogManager.getLogger(DateFormatter.class)
.warn("Date format [{}] contains textual field specifiers that could change in JDK 23", format);
deprecationLogger.warn(
DeprecationCategory.PARSING,
"cldr_date_formats_" + format,
"Date format [{}] contains field specifiers that could change in JDK 23",
format
);
}
}
}

0 comments on commit eb4dc9a

Please sign in to comment.