回答編集履歴
5
追記
test
CHANGED
@@ -17,6 +17,10 @@
|
|
17
17
|
Deprecated. This feature will be removed in Lang 4.0, use isCreatable(String) instead
|
18
18
|
|
19
19
|
Checks whether the String a valid Java number.
|
20
|
+
|
21
|
+
> [中略]
|
22
|
+
|
23
|
+
> Non-hexadecimal strings beginning with a leading zero are treated as octal values. Thus the string 09 will return false, since 9 is not a valid octal value.
|
20
24
|
|
21
25
|
|
22
26
|
|
4
追記
test
CHANGED
@@ -5,6 +5,22 @@
|
|
5
5
|
数値を0から書き始めた場合8進数と見做されます。
|
6
6
|
|
7
7
|
その場合`011`と`063`は合法ですが、`068`と`084`は 0~7 以外の文字を含むので違法です。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
isNumberは、『数値として解釈できるか』判定するようです。
|
12
|
+
|
13
|
+
> **@Deprecated**
|
14
|
+
|
15
|
+
**public static boolean isNumber(String str)**
|
16
|
+
|
17
|
+
Deprecated. This feature will be removed in Lang 4.0, use isCreatable(String) instead
|
18
|
+
|
19
|
+
Checks whether the String a valid Java number.
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
引用元: [NumberUtils (Apache Commons Lang 3.9-SNAPSHOT API)](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/NumberUtils.html#isNumber-java.lang.String-)
|
8
24
|
|
9
25
|
|
10
26
|
|
@@ -23,3 +39,7 @@
|
|
23
39
|
|
24
40
|
|
25
41
|
引用元: [NumberUtils (Apache Commons Lang 3.9-SNAPSHOT API)](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/NumberUtils.html#isDigits-java.lang.String-)
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
isNumberは目的に沿いませんし、しかもDeprecated(非推奨)です。
|
3
追記
test
CHANGED
@@ -5,3 +5,21 @@
|
|
5
5
|
数値を0から書き始めた場合8進数と見做されます。
|
6
6
|
|
7
7
|
その場合`011`と`063`は合法ですが、`068`と`084`は 0~7 以外の文字を含むので違法です。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
解消法
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
単に数字のみで構成されているという判定がしたいなら、isDigitsだけ使えば良いかと。
|
16
|
+
|
17
|
+
> **public static boolean isDigits(String str)**
|
18
|
+
|
19
|
+
Checks whether the String contains only digit characters.
|
20
|
+
|
21
|
+
Null and empty String will return false.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
引用元: [NumberUtils (Apache Commons Lang 3.9-SNAPSHOT API)](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/NumberUtils.html#isDigits-java.lang.String-)
|
2
修正
test
CHANGED
@@ -1 +1,7 @@
|
|
1
|
+
> "011"や"063"などの文字列はこのifに引っかからずエラーとならなかったのですが、なぜか"068"、"084"など一部の値はこのチェックに漏れてエラーとなってしまいました。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
|
-
|
5
|
+
数値を0から書き始めた場合8進数と見做されます。
|
6
|
+
|
7
|
+
その場合`011`と`063`は合法ですが、`068`と`084`は 0~7 以外の文字を含むので違法です。
|
1
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
間違えて投稿しました。編集しますのでしばらくお待ちください。
|