User12341234
User12341234

Reputation: 79

API Method to check if value in a string variable is positive numeric value

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

Answers (1)

sudo
sudo

Reputation: 775

You can use the Apaches commons.lang.math like (null-safe):

NumberUtils.toScaledBigDecimal(strNum).signum() == 1

Upvotes: 1

Related Questions