Thursday, June 19, 2014

Best way to Identifying integer value from String



Best way to Identifying integer value from String


if(stringVariable.trim().matches("^\\d*$")){
// true this is a integer
}

To Decimal number like 1.23

if(("1.23".matches("^\\d+\\.\\d{2}$")){
// this will be truw
}