Home > database >  NumberUtils.isCreatable(String) - how to replace it?
NumberUtils.isCreatable(String) - how to replace it?

Time:10-12

I want to check if some string is number or not. I have a case where '0' is first digit of string and then '9' or '8' is second digit. For example: "0994545", "084354".

I am using NumberUtils.isCreatable(String) from Apache commons 3 library.

Result:

NumberUtils.isCreatable("0994545"); //returns FALSE but it should be TRUE
NumberUtils.isCreatable("084354"); //returns FALSE but it should be TRUE

How can I replace NumberUtils to check if some string is number or not by not using NumberUtils?

CodePudding user response:

Non-hexadecimal strings beginning with a leading zero are treated as octal values. As crystal clearly seen, your input values are not valid octal values. Source

  • Related