List of utility methods to do Int Format
String | addCommas(int value) Adds commas to an integer String finalString = ""; String intStr = "" + value; int strCount = intStr.length(); for (int index = strCount - 1, pointerCount = 0; index >= 0; index--, pointerCount++) { if (pointerCount > 0) { if (pointerCount % 3 == 0) { finalString = "," + finalString; finalString = intStr.charAt(index) + finalString; return finalString; |
String | formatSpeed(int value) format Speed return formatSize(value) + "/s"; |
String | formatSpeed(int speed, String format) format Speed java.text.DecimalFormat df = new java.text.DecimalFormat(format); if (speed < 0) return "0B/s"; if (speed < 1000) { return speed + "B/s"; if (speed < 1000f * 1024.0) return df.format(speed / 1024) + "KB/s"; ... |
String | getDecimalFormat(int i, String numStr) get Decimal Format try { if (numStr != null && !"".equals(numStr)) { BigDecimal bd = new BigDecimal(numStr); bd = bd.setScale(i, BigDecimal.ROUND_HALF_UP); return bd.toString(); } else { return ""; } catch (Exception e) { return ""; |
String | formatGameSize(int size) format Game Size DecimalFormat df = new DecimalFormat("0.00"); if (size > 1024 * 1024) { return String.valueOf(df.format((float) size / (1024 * 1024))) + "M"; } else { return String.valueOf(df.format((float) size / 1024)) + "K"; |
String | formatSpeed(int value) format Speed return formatSize(value) + "/s"; |
String | formatId(String id) format Id return String.format("%s-%s-%s-%s", id.substring(0, 4), id.substring(4, 8), id.substring(8, 12), id.substring(12, 16)); |
String | formatInt(int number) format Int return NumberFormat.getNumberInstance(Locale.US).format(number);
|