List of utility methods to do String to Int Convert
boolean | isNumber(String str) is Number if (isLong(str)) { return true; Pattern pattern = Pattern.compile("(-)?(\\d*)\\.{0,1}(\\d*)"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; return true; |
boolean | isNumber(final String s) is Number if (s == null || s.length() == 0) { return false; int size = s.length(); for (int i = 0; i < size; i++) { char chr = s.charAt(i); if (chr < '0' || '9' < chr) { return false; ... |
boolean | isNumberString(String input) is Number String if (!isNullOrEmpty(input)) { if (input.matches("[0-9]+")) { return true; return false; |
boolean | isNumberic(String str) is Numberic final Pattern p = Pattern.compile("[0-9]*"); final Matcher m = p.matcher(str); return m.matches(); |
int | toInt(Object obj) to Int if (obj == null) return 0; return toInt(obj.toString(), 0); |
int | toInt(String obj) to Int try { return Integer.parseInt(obj); } catch (Exception e) { return 0; |
int | toInt(String str, int defValue) to Int try { return Integer.parseInt(str); } catch (Exception e) { return defValue; |
int | toInt(String str, int defValue) to Int try { return Integer.parseInt(str); } catch (Exception e) { return defValue; |
int | toInteger(String value) to Integer try { return Integer.parseInt(value); } catch (Exception e) { Debug.warning(e); return 0; |
int | toNumber(String str) to Number str = defaultIfBlank(str, "0"); if (isNumber(str)) return Integer.valueOf(str); else return 0; |