List of utility methods to do String to Int Convert
int | parseInt(String str) Parses an string to integer by removing any non-integer character str = str.replaceAll("[^0-9]+", ""); try { return Integer.parseInt(str); } catch (Exception e) { return 0; |
int | parseInt(String arg, int defaultValue) parse Int if (arg == null) { return defaultValue; try { return Integer.parseInt(arg); } catch (NumberFormatException e) { return defaultValue; |
int[] | stringToIntArray(String arrString, String separator) string To Int Array try { String s = arrString.replaceAll("\\s", ""); String[] sa = s.split(separator); int[] ia = new int[sa.length]; for (int i = 0; i < sa.length; i++) { if (isDigits(sa[i])) { ia[i] = Integer.parseInt(sa[i]); } else { ... |
ArrayList | getIntegerArrayList(String strInput) get Integer Array List ArrayList<Integer> ret = new ArrayList<Integer>(); String[] shareIDs = strInput.split(","); if (null != shareIDs && shareIDs.length > 0) { for (int i = 0; i < shareIDs.length; i++) { try { ret.add(Integer.valueOf(shareIDs[i])); } catch (Exception e) { e.printStackTrace(); ... |
boolean | validInt(CharSequence integer) valid Int if (!TextUtils.isEmpty(integer)) { try { Integer.parseInt(integer.toString()); return true; } catch (NumberFormatException ex) { return false; ... |
int | parseIntOrZero(CharSequence charSequence) parse Int Or Zero if (!TextUtils.isEmpty(charSequence)) { try { return Integer.parseInt(charSequence.toString()); } catch (NumberFormatException ignore) { return 0; |
int | parseInt(String string, int defValue) Parse String to integer. try { return Integer.parseInt(string); } catch (NumberFormatException nfe) { return defValue; |
int | convertStringToInt(String str) convert String To Int return convertStringToInt(str, 0);
|
int | convertStringToInt(String str, int failValue) convert String To Int if (str == null) { return failValue; try { return Integer.parseInt(str); } catch (Exception e) { e.printStackTrace(); return failValue; |