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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit 47aea5993d289b82c7febdbf9b05ffaad31b6ec9
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jan 18 09:29:05 2026 -0500

    Sort the available TimeZone IDs once.
---
 .../java/org/apache/commons/lang3/time/FastDateParser.java     |  3 +--
 src/main/java/org/apache/commons/lang3/time/TimeZones.java     | 10 ++++++++++
 .../lang3/time/FastDateParser_TimeZoneStrategyTest.java        |  2 +-
 .../commons/lang3/time/FastDatePrinterTimeZonesTest.java       |  2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java 
b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
index b5f7afe21..b2a12157f 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
@@ -44,7 +44,6 @@
 import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
-import org.apache.commons.lang3.ArraySorter;
 import org.apache.commons.lang3.CharUtils;
 import org.apache.commons.lang3.LocaleUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -581,7 +580,7 @@ static boolean skipTimeZone(final String tzId) {
                 }
             }
             // Order is undefined.
-            for (final String tzId : 
ArraySorter.sort(TimeZone.getAvailableIDs())) {
+            for (final String tzId : TimeZones.SORTED_AVAILABLE_IDS) {
                 if (skipTimeZone(tzId)) {
                     continue;
                 }
diff --git a/src/main/java/org/apache/commons/lang3/time/TimeZones.java 
b/src/main/java/org/apache/commons/lang3/time/TimeZones.java
index f9f3e7ef8..db498bcc8 100644
--- a/src/main/java/org/apache/commons/lang3/time/TimeZones.java
+++ b/src/main/java/org/apache/commons/lang3/time/TimeZones.java
@@ -20,6 +20,7 @@
 import java.time.ZoneId;
 import java.util.TimeZone;
 
+import org.apache.commons.lang3.ArraySorter;
 import org.apache.commons.lang3.JavaVersion;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.SystemProperties;
@@ -82,6 +83,15 @@ public static TimeZone toTimeZone(final TimeZone timeZone) {
         return ObjectUtils.getIfNull(timeZone, TimeZone::getDefault);
     }
 
+    /**
+     * The sorted available IDs.
+     * <p>
+     * Make a defensive copy, just in case.
+     * </p>
+     * @see TimeZone#getAvailableIDs()
+     */
+    static final String[] SORTED_AVAILABLE_IDS = 
ArraySorter.sort(TimeZone.getAvailableIDs().clone());
+
     /** Do not instantiate. */
     private TimeZones() {
     }
diff --git 
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
 
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
index 517918c79..b30f2c2aa 100644
--- 
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
+++ 
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
@@ -216,7 +216,7 @@ private void 
testTimeZoneStrategyPattern_TimeZone_getAvailableIDs(final Locale l
         Objects.requireNonNull(locale, "locale");
         assumeFalse(LocaleUtils.isLanguageUndetermined(locale), () -> 
toFailureMessage(locale, null, null));
         assumeTrue(LocaleUtils.isAvailableLocale(locale), () -> 
toFailureMessage(locale, null, null));
-        for (final String id : ArraySorter.sort(TimeZone.getAvailableIDs())) {
+        for (final String id : TimeZones.SORTED_AVAILABLE_IDS) {
             final TimeZone timeZone = TimeZones.getTimeZone(id);
             final String displayName = timeZone.getDisplayName(locale);
             final FastDateParser parser = new FastDateParser("z", timeZone, 
locale);
diff --git 
a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java 
b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java
index c09726e96..8dd3e9f11 100644
--- 
a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java
+++ 
b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTimeZonesTest.java
@@ -32,7 +32,7 @@ class FastDatePrinterTimeZonesTest extends AbstractLangTest {
     private static final String PATTERN = "h:mma z";
 
     public static Stream<TimeZone> data() {
-        return 
Stream.of(TimeZone.getAvailableIDs()).map(TimeZones::getTimeZone);
+        return 
Stream.of(TimeZones.SORTED_AVAILABLE_IDS).map(TimeZones::getTimeZone);
     }
 
     @ParameterizedTest

Reply via email to