List of utility methods to do Long Number Format
String | format(long s) format if (s < 10) { return "0" + s; } else { return "" + s; |
String | format(long seconds) format long minutes = seconds / 60; long secs = seconds - (minutes * 60); String time = "" + minutes + ":"; if (secs < 10) { time += "0"; time += secs; return time; ... |
String | format(long value) format if (value < 0) return "-" + format(-value); if (value == 0) return "0B"; final int mag = (int) (Math.log10(value) / Math.log10(1024)); final float adjustedSize = (float) value / (1L << (mag * 10)); final String format = (mag > 2 ? "%.2f" : "%.0f") + "%s"; return String.format(format, adjustedSize, SIZE_SUFFIXES[mag]); ... |
long | format(Long value) Converts Byte values into Megabyte values. return value / 1024 / 1024;
|
String | formatLong(long inLong, int inLen, boolean inComma, int inCommaPos) This method is to format the long. String outString = ""; int countComma = 0; long tempLong; boolean fNegative = false; if (inLong < 0) { fNegative = true; inLong = inLong * (-1); if (inLong == 0) outString = "0"; else { while (inLong > 0) { if (inComma && countComma == inCommaPos) { outString = "," + outString; countComma = 0; tempLong = inLong % 10; outString = Long.toString(tempLong) + outString; inLong = (long) (inLong / 10); countComma++; if (fNegative) outString = "-" + outString; return outString; |
String | formatLong(Long number) format Long if (number == null) { number = 0L; return number.toString(); |
String | formatLong(long val, int size) format Long String formatter = "%0" + size + "d"; return String.format(formatter, val); |
String | formatLong(long value) Formats a long value and prepends it with a - or + This functions is used for showing the diff values for test runs if (value == 0) { return "0"; } else if (value < 0) { return Long.toString(value); } else { return "+" + Long.toString(value); |
String | formatLong(long value) Formats a value using spaces to separate thousands as: ddd ddd ddd. boolean isNegative = value < 0; if (isNegative) { value = -value; char[] buffer = new char[1 + 19 + 6]; int index = buffer.length - 1; if (value == 0) { buffer[index--] = '0'; ... |
String | formatLong(long value, int length) Format long value boolean isPostive = value >= 0; value = isPostive ? value : value * -1; String result = formatStr2("" + value, length - 1); if (isPostive) result = " " + result; else result = "-" + result; return result; ... |