Java Utililty Methods Money Format

List of utility methods to do Money Format

Description

The list of methods to do Money Format are organized into topic(s).

Method

StringgetMoneyString(double money)
get Money String
NumberFormat nf = NumberFormat.getInstance();
((DecimalFormat) nf).applyPattern("#,000.00");
String moneyStr = nf.format(money);
return "" + moneyStr;
StringhourAndMinutesToString(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);
StringmoneyDelFormat(String s)
money Del Format
String formatString = "";
if (s != null && s.length() >= 1) {
    formatString = s.replaceAll(",", "");
return formatString;
Stringstr2money(String str)
strmoney
try {
    double amt = Long.parseLong(str) / 100.0D;
    return formatMoney(amt);
} catch (Exception e) {
    System.err.println(e);
return str;
StringtoMemoryString(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)
...
StringtoMemoryUnits(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")) {
...
StringtoMoney(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;