List of utility methods to do String to Int Convert
String | amount2String(String amount) amount String String temp = amount.replace(".", "").replace(",", ""); return String.format("%012d", Long.parseLong(temp)); |
int | String2Int(String str) String Int try { int value = Integer.valueOf(str); return value; } catch (Exception e) { e.printStackTrace(); return 0; |
int | string2Int(String str) string Int try { int value = Integer.valueOf(str); return value; } catch (Exception e) { e.printStackTrace(); return 0; |
boolean | isTextInteger(String texto) is Text Integer boolean out = false; if (texto != null) { texto = texto.toLowerCase().trim(); try { Integer.parseInt(texto); return true; } catch (Exception e) { return false; ... |
int | getInt(String str, int defaultValue) get Int if (str == null) return defaultValue; try { return Integer.parseInt(str); } catch (Exception e) { return defaultValue; |
int | getIntFromStr(String str) get Int From Str int i = 0; try { i = Integer.valueOf(str); } catch (NumberFormatException e) { return i; |
int | getIntValue(String str) get Int Value if (str != null && str.length() > 0) { try { return Integer.parseInt(str); } catch (Exception e) { return 0; |
int | getFirstInteger(String value) get First Integer StringBuilder sb = new StringBuilder(); char[] charArray = value.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (charArray[i] >= '0' && charArray[i] <= '9') { sb.append(charArray[i]); } else { break; return (sb.length() == 0 ? 0 : Integer.parseInt(sb.toString())); |
Integer | tryParse(String value, int defaultValue) try Parse try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; |
String | tryParse(String value, String defaultValue) try Parse try { return String.valueOf(Integer.parseInt(value)); } catch (NumberFormatException e) { return defaultValue; |