List of utility methods to do Integer Format
String | formatInt(int i, int radix, int len) Format an integer into the specified radix, zero-filled. String s = Integer.toString(i, radix); StringBuffer buf = new StringBuffer(); for (int j = 0; j < len - s.length(); j++) buf.append("0"); buf.append(s); return buf.toString(); |
String | formatInt(int in, int precision) convert a double into a String with a given precision default double formatting is not very pretty String ret = Integer.toString(in); if (ret.length() > precision) throw new IllegalArgumentException("Cannot write " + in + " in " + precision + " digits"); while (ret.length() < precision) ret = "0" + ret; return (ret); |
String | formatInt(int myint, int maxint) public function formatInt() Integer myInt = Integer.valueOf(myint); Integer maxInt = Integer.valueOf(maxint); int prefix = maxInt.toString().length() - myInt.toString().length(); StringBuffer formattedInt = new StringBuffer(); for (int i = 0; i < prefix; i++) { formattedInt.append(" "); formattedInt.append(myint + " "); ... |
String | formatINT(int n) format INT String s = "" + n; s = reverse(s); String st = ""; for (int i = 0; i < s.length(); i++) { if (i != 0 && i % 3 == 0) st += ","; st += s.charAt(i); return reverse(st); |
String | formatInt(int n) format Int return String.format("%,d", n); |
CharSequence | formatInt(int value, int length) Convert an int value to a String with leading zeros StringBuilder result = new StringBuilder(length); if (value < 0) { result.append('-'); String nr = Integer.toString(Math.abs(value)); for (int i = 0; i < length - nr.length(); i++) { result.append('0'); result.append(nr); return result; |
String | formatInt(int value, int numDigit) Format an integer value with specifie integer digits number if (numDigit == 0) { return ""; String stringValue = Integer.toString(value); if (numDigit < 0) { return stringValue; int lengthValue = stringValue.length(); ... |
String | formatInt(int value, int width) format Int StringBuilder sb = new StringBuilder(); sb.append(value); if (width > sb.length()) { sb.insert(0, SPACES12, 0, width - sb.length()); return sb.toString(); |
Integer | formatInt(String value) Checks if the value can safely be converted to a int primitive. Integer result = null; try { result = new Integer(value); } catch (Exception e) { return result; |
Integer | formatInt(String value) Checks if the value can safely be converted to a int primitive. if (isBlankOrNull(value)) { return null; try { return new Integer(value); } catch (NumberFormatException e) { return null; |