diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 036c643b9..811cbc297 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
+ NumberUtils#isNumber does not allow for hex 0XABCD
StringUtils.toEncodedString(byte[], Charset) needlessly throws UnsupportedEncodingException
Add APIs MutableBoolean setTrue() and setFalse()
ConstantInitializerTest fails when building with IBM JDK 7
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index 33a2dd8e7..f1054eeb2 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -1345,7 +1345,13 @@ public class NumberUtils {
boolean foundDigit = false;
// deal with any possible sign up front
final int start = (chars[0] == '-') ? 1 : 0;
- if (sz > start + 1 && chars[start] == '0' && chars[start + 1] == 'x') {
+ if (sz > start + 1 && chars[start] == '0'
+ &&
+ (
+ (chars[start + 1] == 'x') ||
+ (chars[start + 1] == 'X')
+ )
+ ) {
int i = start + 2;
if (i == sz) {
return false; // str == "0x"
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index 9b52ac6de..d211b6c49 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -1225,6 +1225,12 @@ public class NumberUtilsTest {
compareIsNumberWithCreateNumber("1.1L", false); // LANG-664
}
+ @Test
+ public void testLANG972() {
+ compareIsNumberWithCreateNumber("0xABCD", true);
+ compareIsNumberWithCreateNumber("0XABCD", true);
+ }
+
private void compareIsNumberWithCreateNumber(final String val, final boolean expected) {
final boolean isValid = NumberUtils.isNumber(val);
final boolean canCreate = checkCreateNumber(val);