List of utility methods to do Number Format Pattern
String | format(String value) Format only six decimal digits after decimal point. String subStr = null; int dot = value.indexOf("."); subStr = value.substring(0, value.length() < dot + 7 ? value.length() : dot + 7); return subStr; |
String | formatAmtByComma(String amt, int len) format Amt By Comma if (null == amt || amt.length() < 1) { return "0"; NumberFormat formater = null; BigDecimal num = new BigDecimal(amt); if (len == 0) { formater = new DecimalFormat("###,###"); } else { ... |
String | formatBigNumber(long value) Format like ###000000 return bigCountFormat.format(value);
|
String | formatBitRate(long bytes) Returns human readable bit rate, to be displayed as a label. String unit; double value; long bits = bytes * 8; if (bits > GIGA) { value = bits / GIGA; unit = GBITS_UNIT; if (value > 10.0) { value = 10.0; ... |
String | formatBytes(long bytes) format Bytes if (bytes < 1024L) { return bytes + " bytes"; if (bytes < 1024L * 1024L) { return formatOneDecimal(bytes, 1024L) + " KB"; if (bytes < 1024L * 1024L * 1024L) { return formatOneDecimal(bytes, 1024L * 1024L) + " MB"; ... |
String | formatBytes(long bytes) Format bytes to KB, MB or GB. double size = 0; if (bytes < 1024) { return bytes + " Bytes"; } else if (bytes < 1048576) { size = bytes / 1024; return formatDecimal(size) + " KB"; } else if (bytes < 1073741824) { size = bytes / 1048576; ... |
String | formatBytes(long bytes) Format the bytes into readable text double value = bytes; String unit = "B"; if (bytes >= 1024) { int exponent = (int) (Math.log(bytes) / Math.log(1024)); exponent = Math.min(exponent, 4); switch (exponent) { case 1: unit = "KB"; ... |
String | formatBytes(long bytes) Format a number of bytes into Megabytes/Kilobytes depending on the quantity. if (bytes > 1024 * 1024) { return MEGABYTE_FORMAT.format(((double) bytes) / (1024 * 1024)); } else if (bytes > 1024) { return KILOBYTE_FORMAT.format(((double) bytes) / (1024)); } else { return Long.toString(bytes) + "B"; |
String | formatBytes(long numBytes) format Bytes StringBuffer buf = new StringBuffer(); boolean bDetails = true; double num = numBytes; if (numBytes < KB) { buf.append(numBytes + " B"); bDetails = false; } else if (numBytes < MB) { buf.append(dfmt(num / KB) + " KB"); ... |
String | formatDashboardNumber(Number amount) format Dashboard Number return dashboardFormat.format(amount);
|