List of utility methods to do Integer Format
String | formatInteger(Integer value) Formats an integer attribute. if (value != null) { return value.toString(); return null; |
String | formatIntegerBase2WithLeadingZeros(long x, int length) format Integer Base With Leading Zeros return pad(Long.toBinaryString(x), length, 1);
|
String | formatIntegerWithLeadingZeros(long x, int radix, int length) format Integer With Leading Zeros return radix == 2 ? formatIntegerBase2WithLeadingZeros(x, length)
: radix == 8 ? formatIntegerBase8WithLeadingZeros(x, length)
: radix == 16 ? formatIntegerBase16WithLeadingZeros(x, length)
: formatIntegerBaseSomeWithLeadingZeros(x, radix, length);
|
String | formatIntents(String[] intents) format Intents StringBuilder sb = new StringBuilder(); boolean first = true; for (String intent : intents) { if (first) { first = false; } else { sb.append(' '); sb.append(intent); return sb.toString(); |
String | formatInterval(long interval) Returns human readable representation of interval value in days, hours etc. long days = interval / (24 * 60 * 60); interval -= days * 24 * 60 * 60; long hours = interval / (60 * 60); interval -= hours * 60 * 60; long minutes = interval / 60; interval -= minutes * 60; long seconds = interval; StringBuffer buff = new StringBuffer(); ... |
String | formatIntoHHMMSS(int secsIn) format Into HHMMSS int hours = secsIn / 3600, remainder = secsIn % 3600, minutes = remainder / 60, seconds = remainder % 60; return ((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds); |
String | formatIntoHHMMSS(long l) format Into HHMMSS long hours = l / 3600, remainder = l % 3600, minutes = remainder / 60, seconds = remainder % 60; return ((hours < 10 ? "0" : "") + hours + "h" + (minutes < 10 ? "0" : "") + minutes + "m" + (seconds < 10 ? "0" : "") + seconds + "s"); |
String | formatIntOrLong(long v) format Int Or Long if (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE) return v + ""; return v + "L"; |
String | formatInts(int[] vals) Formats an array of ints. String res = ""; if (vals == null) res = "(null)"; else { res = "["; for (int ii = 0; ii < vals.length; ii++) { if (ii > 0) res += " "; ... |
String | formatIntWithPadding(int value, int length, char pad) format Int With Padding String valueStr = value + ""; int diff = length - valueStr.length(); StringBuilder strBuilder = new StringBuilder(); if (diff > 0) { while (diff > 0) { diff--; strBuilder.append(pad); strBuilder.append(valueStr); valueStr = strBuilder.toString(); return valueStr; |