|
23 | 23 | import java.text.ParseException; |
24 | 24 | import java.text.ParsePosition; |
25 | 25 | import java.text.SimpleDateFormat; |
| 26 | +import java.time.ZoneId; |
26 | 27 | import java.util.ArrayList; |
27 | 28 | import java.util.Arrays; |
28 | 29 | import java.util.Calendar; |
|
46 | 47 |
|
47 | 48 | import org.apache.commons.lang3.ArraySorter; |
48 | 49 | import org.apache.commons.lang3.CharUtils; |
| 50 | +import org.apache.commons.lang3.JavaVersion; |
49 | 51 | import org.apache.commons.lang3.LocaleUtils; |
| 52 | +import org.apache.commons.lang3.SystemUtils; |
50 | 53 |
|
51 | 54 | /** |
52 | 55 | * FastDateParser is a fast and thread-safe version of {@link java.text.SimpleDateFormat}. |
@@ -532,7 +535,7 @@ public String toString() { |
532 | 535 | for (final String[] zoneNames : zones) { |
533 | 536 | // offset 0 is the time zone ID and is not localized |
534 | 537 | final String tzId = zoneNames[ID]; |
535 | | - if (tzId.equalsIgnoreCase(TimeZones.GMT_ID)) { |
| 538 | + if (isInvalidTimeZoneId(tzId)) { |
536 | 539 | continue; |
537 | 540 | } |
538 | 541 | final TimeZone tz = TimeZone.getTimeZone(tzId); |
@@ -561,7 +564,7 @@ public String toString() { |
561 | 564 | } |
562 | 565 | // Order is undefined. |
563 | 566 | for (final String tzId : ArraySorter.sort(TimeZone.getAvailableIDs())) { |
564 | | - if (tzId.equalsIgnoreCase(TimeZones.GMT_ID)) { |
| 567 | + if (isInvalidTimeZoneId(tzId)) { |
565 | 568 | continue; |
566 | 569 | } |
567 | 570 | final TimeZone tz = TimeZone.getTimeZone(tzId); |
@@ -612,6 +615,12 @@ public String toString() { |
612 | 615 | return "TimeZoneStrategy [locale=" + locale + ", tzNames=" + tzNames + ", pattern=" + pattern + "]"; |
613 | 616 | } |
614 | 617 |
|
| 618 | + private static boolean isInvalidTimeZoneId(String tzId) { |
| 619 | + return tzId.equalsIgnoreCase(TimeZones.GMT_ID) |
| 620 | + || |
| 621 | + (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_25) |
| 622 | + && ZoneId.SHORT_IDS.containsKey(tzId)); |
| 623 | + } |
615 | 624 | } |
616 | 625 |
|
617 | 626 | /** |
|
0 commit comments