List of utility methods to do String to Long Convert
Long | stringToLong(String input) string To Long try { return Long.parseLong(input); } catch (NumberFormatException e) { return 0l; |
String | longsToString(long... longs) longs To String StringBuilder string = new StringBuilder(); for (int i = 0; i < longs.length; i++) { long aLong = longs[i]; string.append(aLong); if (i + 1 < longs.length) string.append(","); return string.toString(); ... |
long[] | parseCSLongs(String s) parse CS Longs if (s == null) { return null; String[] elements = s.split(","); long[] result = new long[elements.length]; for (int index = 0; index < elements.length; index++) { Long value = parseLong(elements[index]); if (value != null) { ... |
Long | parseLong(String s) parse Long try { return new Long(s); } catch (NumberFormatException e) { return null; |
long | parseLongWithDefault(String s, long defValue) parse Long With Default if (s == null) { return defValue; try { return Long.parseLong(s); } catch (NumberFormatException e) { return defValue; |
long | parseLong(String s, long iDefault) Parses the long value of the specified string. if (s == null || s.equals("")) return iDefault; try { s = s.trim().replaceAll(",", ""); final int l = s.indexOf('.'); if (l > 0) s = s.substring(0, l); return Long.parseLong(s); ... |
long | safeParseLong(String number, long fallback) Parse an long from the given string, falling back to the provided number in case of failure. try { return Long.parseLong(number); } catch (NumberFormatException nfe) { return fallback; |