Victor
Victor

Reputation: 17107

Numeric validation in Commons Lang

While using the org.apache.commons.lang.math.NumberUtils.isNumber(String str) function, I see that passing a string like "1f" passes validation while passing "1a" fails.

What kind of alphabets are allowed here?

Upvotes: 2

Views: 778

Answers (3)

mre
mre

Reputation: 44250

Jumping on the bandwagon...

enter image description here

Upvotes: 4

RMT
RMT

Reputation: 7070

the 1f is taking the 1 as a float.

"1a" won't be considered as a hexadecimal value because it needs the 0x in front of it,

ex: "0x1a"

Upvotes: 2

JB Nizet
JB Nizet

Reputation: 692231

From the documentation:

Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).

1f means the float number 1.

Upvotes: 2

Related Questions