Reputation: 79
I have a String variable in java,
String strNum = "-90.29";
Apart from regex
, is there any API method available to check if strNum
contains a valid positive decimal value.
Can anyone please help?
Upvotes: 0
Views: 174
Reputation: 775
You can use the Apaches commons.lang.math like (null-safe):
NumberUtils.toScaledBigDecimal(strNum).signum() == 1
Upvotes: 1