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
The following commit(s) were added to refs/heads/master by this push:
new bfcaa941b Add
org.apache.commons.lang3.time.FastDateParser_TimeZoneStrategyTest.testJava25DeprecatedZoneId(String)
bfcaa941b is described below
commit bfcaa941b0849956972517c8559c0827c8fe5386
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Nov 3 07:14:14 2025 -0500
Add
org.apache.commons.lang3.time.FastDateParser_TimeZoneStrategyTest.testJava25DeprecatedZoneId(String)
---
.../time/FastDateParser_TimeZoneStrategyTest.java | 23 +++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
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 4aa50f8e8..3d2a975d4 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
@@ -16,13 +16,16 @@
*/
package org.apache.commons.lang3.time;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.text.DateFormatSymbols;
import java.text.ParseException;
+import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
@@ -41,6 +44,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
import org.junitpioneer.jupiter.DefaultLocale;
import org.junitpioneer.jupiter.DefaultTimeZone;
import org.junitpioneer.jupiter.ReadsDefaultLocale;
@@ -73,6 +77,24 @@ private String[][] getZoneStringsSorted(final Locale locale)
{
return
ArraySorter.sort(DateFormatSymbols.getInstance(locale).getZoneStrings(),
Comparator.comparing(array -> array[0]));
}
+ /**
+ * Tests that known short {@link ZoneId}s still parse since all short IDs
are deprecated starting in Java 25, but are not removed.
+ *
+ * TODO: Why don't all short IDs parse, even on Java 8?
+ *
+ * @throws ParseException Thrown on test failure.
+ */
+ @ParameterizedTest
+ @ValueSource(strings = { "ACT", "CST" })
+ void testJava25DeprecatedZoneId(final String shortId) throws
ParseException {
+ final FastDateParser parser = new FastDateParser("dd.MM.yyyy HH:mm:ss
z", TimeZone.getTimeZone(shortId), Locale.getDefault());
+ final Date date1 = parser.parse("26.10.2014 02:00:00 " + shortId);
+ // 1) parsing returns a value and doesn't throw.
+ assertNotNull(date1);
+ // 2) Something reasonable, note that getYear() subtracts 1900.
+ assertEquals(2014, date1.getYear() + 1900);
+ }
+
@Test
void testLang1219() throws ParseException {
final FastDateParser parser = new FastDateParser("dd.MM.yyyy HH:mm:ss
z", TimeZone.getDefault(), Locale.GERMAN);
@@ -86,7 +108,6 @@ void testLang1219() throws ParseException {
void testTimeZoneStrategy_DateFormatSymbols(final Locale locale) {
testTimeZoneStrategyPattern_DateFormatSymbols_getZoneStrings(locale);
}
-
@ParameterizedTest
@MethodSource("org.apache.commons.lang3.LocaleUtils#availableLocaleList()")
void testTimeZoneStrategy_TimeZone(final Locale locale) {