1616 */
1717package org .apache .commons .lang3 .time ;
1818
19+ import static org .junit .jupiter .api .Assertions .assertEquals ;
1920import static org .junit .jupiter .api .Assertions .assertNotEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
2022import static org .junit .jupiter .api .Assertions .fail ;
2123import static org .junit .jupiter .api .Assumptions .assumeFalse ;
2224import static org .junit .jupiter .api .Assumptions .assumeTrue ;
2325
2426import java .text .DateFormatSymbols ;
2527import java .text .ParseException ;
28+ import java .time .ZoneId ;
2629import java .util .ArrayList ;
2730import java .util .Comparator ;
2831import java .util .Date ;
4144import org .junit .jupiter .api .Test ;
4245import org .junit .jupiter .params .ParameterizedTest ;
4346import org .junit .jupiter .params .provider .MethodSource ;
47+ import org .junit .jupiter .params .provider .ValueSource ;
4448import org .junitpioneer .jupiter .DefaultLocale ;
4549import org .junitpioneer .jupiter .DefaultTimeZone ;
4650import org .junitpioneer .jupiter .ReadsDefaultLocale ;
@@ -73,6 +77,24 @@ private String[][] getZoneStringsSorted(final Locale locale) {
7377 return ArraySorter .sort (DateFormatSymbols .getInstance (locale ).getZoneStrings (), Comparator .comparing (array -> array [0 ]));
7478 }
7579
80+ /**
81+ * Tests that known short {@link ZoneId}s still parse since all short IDs are deprecated starting in Java 25, but are not removed.
82+ *
83+ * TODO: Why don't all short IDs parse, even on Java 8?
84+ *
85+ * @throws ParseException Thrown on test failure.
86+ */
87+ @ ParameterizedTest
88+ @ ValueSource (strings = { "ACT" , "CST" })
89+ void testJava25DeprecatedZoneId (final String shortId ) throws ParseException {
90+ final FastDateParser parser = new FastDateParser ("dd.MM.yyyy HH:mm:ss z" , TimeZone .getTimeZone (shortId ), Locale .getDefault ());
91+ final Date date1 = parser .parse ("26.10.2014 02:00:00 " + shortId );
92+ // 1) parsing returns a value and doesn't throw.
93+ assertNotNull (date1 );
94+ // 2) Something reasonable, note that getYear() subtracts 1900.
95+ assertEquals (2014 , date1 .getYear () + 1900 );
96+ }
97+
7698 @ Test
7799 void testLang1219 () throws ParseException {
78100 final FastDateParser parser = new FastDateParser ("dd.MM.yyyy HH:mm:ss z" , TimeZone .getDefault (), Locale .GERMAN );
@@ -86,7 +108,6 @@ void testLang1219() throws ParseException {
86108 void testTimeZoneStrategy_DateFormatSymbols (final Locale locale ) {
87109 testTimeZoneStrategyPattern_DateFormatSymbols_getZoneStrings (locale );
88110 }
89-
90111 @ ParameterizedTest
91112 @ MethodSource ("org.apache.commons.lang3.LocaleUtils#availableLocaleList()" )
92113 void testTimeZoneStrategy_TimeZone (final Locale locale ) {
0 commit comments