List of utility methods to do Money Format
String | getMoneyString(double money) get Money String NumberFormat nf = NumberFormat.getInstance(); ((DecimalFormat) nf).applyPattern("#,000.00"); String moneyStr = nf.format(money); return "" + moneyStr; |
String | hourAndMinutesToString(int hours, int minutes) hour And Minutes To String String minutesStr = (minutes < 10 ? "0" : "") + minutes; String hoursStr = (hours < 10 ? "0" : "") + hours; return new String(hoursStr + ":" + minutesStr); |
String | moneyDelFormat(String s) money Del Format String formatString = ""; if (s != null && s.length() >= 1) { formatString = s.replaceAll(",", ""); return formatString; |
String | str2money(String str) strmoney try { double amt = Long.parseLong(str) / 100.0D; return formatMoney(amt); } catch (Exception e) { System.err.println(e); return str; |
String | toMemoryString(double bytes) to Memory String double display = bytes; if (display < 1024) return display + "b"; display /= 1024.0; if (display < 1024) return String.format("%-1.1f", display) + "kb"; display /= 1024.0; if (display < 1024) ... |
String | toMemoryUnits(double value) to Memory Units if (value == 0) { return "0"; if (value < (10l << 10)) { String val = String.format("%.2f", value).trim(); if (val.endsWith(".00")) { val = val.substring(0, val.length() - 3); } else if (val.indexOf('.') > 0 && val.endsWith("0")) { ... |
String | toMoney(long amount) to Money DecimalFormat df = new DecimalFormat("00"); long bigPart = amount / 100; long smallPart = amount % 100; String result = String.format("%d.%s", bigPart, df.format(smallPart)); return result; |