[OmniFaces utilities] The
isNumber()
method returns true
if the given string is parseable as a number. I.e. it is not null, nor blank and contains solely digits. I.e., it won't throw a NumberFormatException
when parsing as Long
.[OmniFaces utilities] The
isDecimal()
method returns true
if the given string is parseable as a decimal. I.e. it is not null, nor blank and contains solely digits. I.e., it won't throw a NumberFormatException
when parsing as Double
.Method Utils#isNumber():
Method Utils#isDecimal():
Usage:
import org.omnifaces.util.Utils;
...
String a = "";
String b = "3";
String c = "3L";
String d = "3.14";
String e = "3.14f";
String f = "3.14d";
// a
boolean isANumber = Utils.isNumber(a); // false
boolean isADecimal = Utils.isDecimal(a); // false
// b
boolean isBNumber = Utils.isNumber(b); // true
boolean isBDecimal = Utils.isDecimal(b); // true
// c
boolean isCNumber = Utils.isNumber(c); // false
boolean isCDecimal = Utils.isDecimal(c); // false
// d
boolean isDNumber = Utils.isNumber(d); // false
boolean isDDecimal = Utils.isDecimal(d); // true
// e
boolean isENumber = Utils.isNumber(e); // false
boolean isEDecimal = Utils.isDecimal(e); // true
// f
boolean isFNumber = Utils.isNumber(f); // false
boolean isFDecimal = Utils.isDecimal(f); // true
Niciun comentariu :
Trimiteți un comentariu