Many times you want to check if the inputText contains numbers of decimals only e.g. getting amount in input.
public boolean isValidNumber(String inputNumber){
Pattern p = Pattern.compile('\\d+(\\.\\d+)?');
Matcher m =p.matcher(inputNumber);
return m.Matches();
}
The above method return true if it is a valid number else return false.
No comments:
Post a Comment