This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
The following commit(s) were added to refs/heads/master by this push:
new f5494fd0 Fix sql time and timestamp locale tests on java 20+ (#410).
f5494fd0 is described below
commit f5494fd0a0f3b48c9bc140e228bd67571fe1ae47
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jul 2 19:38:22 2026 +0000
Fix sql time and timestamp locale tests on java 20+ (#410).
Refactor the copy-pasta from the PR.
---
src/changes/changes.xml | 1 +
.../beanutils2/converters/AbstractDateConverterTest.java | 12 ++++++++++++
.../beanutils2/sql/converters/SqlTimeConverterTest.java | 11 -----------
.../beanutils2/sql/converters/SqlTimestampConverterTest.java | 9 ---------
4 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 87125aff..9db3f4d7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,7 @@
<action type="fix" dev="ggregory" due-to="Digiscrypt Technologies, Gary
Gregory">Do not initialize arbitrary classes in EnumConverter (#398).</action>
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Stop
narrowing BigInteger and BigDecimal in StringLocaleConverter (#408).</action>
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Reject
out-of-range values in LongLocaleConverter (#406).</action>
+ <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Fix
sql time and timestamp locale tests on java 20+ (#410).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Use varargs for
org.apache.commons.beanutils2.MethodUtils.getAccessibleMethod(Class, String,
Class...), and remove last argument variants using Class[] and Class.</action>
<action type="add" dev="ggregory" due-to="SethFalco, Melloware, Gary
Gregory">Add Instant converter and improve enum converter #49.</action>
diff --git
a/src/test/java/org/apache/commons/beanutils2/converters/AbstractDateConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/converters/AbstractDateConverterTest.java
index 5f2b8748..f2cb42ea 100644
---
a/src/test/java/org/apache/commons/beanutils2/converters/AbstractDateConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/converters/AbstractDateConverterTest.java
@@ -50,6 +50,18 @@ import org.junit.jupiter.api.Test;
*/
public abstract class AbstractDateConverterTest<T> {
+ private static final String NB_SPACE = "\u202f";
+
+ /**
+ * Gets the separator that precedes the AM/PM field in the US SHORT time
format. Java 20 and up (CLDR) use a narrow no-break space (U+202F) here,
+ * earlier versions use a regular space.
+ *
+ * @return the separator that precedes the AM/PM field in the US SHORT
time format.
+ */
+ protected static String amPmSeparator() {
+ return DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US).format(new Date()).contains(NB_SPACE) ? NB_SPACE : " ";
+ }
+
/**
* Gets the expected type
*
diff --git
a/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimeConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimeConverterTest.java
index ca7e7854..918290c7 100644
---
a/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimeConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimeConverterTest.java
@@ -18,9 +18,7 @@
package org.apache.commons.beanutils2.sql.converters;
import java.sql.Time;
-import java.text.DateFormat;
import java.util.Calendar;
-import java.util.Date;
import java.util.Locale;
import org.apache.commons.beanutils2.converters.AbstractDateConverterTest;
@@ -31,15 +29,6 @@ import org.junit.jupiter.api.Test;
*/
class SqlTimeConverterTest extends AbstractDateConverterTest<Time> {
- /**
- * Gets the separator that precedes the AM/PM field in the US SHORT time
format. Java 20 and up (CLDR) use a narrow no-break space (U+202F) here,
- * earlier versions use a regular space.
- */
- private static String amPmSeparator() {
- final String formatted = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US).format(new Date());
- return formatted.contains("\u202f") ? "\u202f" : " ";
- }
-
/**
* Gets the expected type
*
diff --git
a/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimestampConverterTest.java
b/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimestampConverterTest.java
index c8247263..902735e4 100644
---
a/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimestampConverterTest.java
+++
b/src/test/java/org/apache/commons/beanutils2/sql/converters/SqlTimestampConverterTest.java
@@ -31,15 +31,6 @@ import org.junit.jupiter.api.Test;
*/
class SqlTimestampConverterTest extends AbstractDateConverterTest<Timestamp> {
- /**
- * Gets the separator that precedes the AM/PM field in the US SHORT time
format. Java 20 and up (CLDR) use a narrow no-break space (U+202F) here,
- * earlier versions use a regular space.
- */
- private static String amPmSeparator() {
- final String formatted = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US).format(new Date());
- return formatted.contains("\u202f") ? "\u202f" : " ";
- }
-
/**
* Gets the expected type
*