Example usage for java.text DecimalFormat getCurrencyInstance

List of usage examples for java.text DecimalFormat getCurrencyInstance

Introduction

In this page you can find the example usage for java.text DecimalFormat getCurrencyInstance.

Prototype

public static NumberFormat getCurrencyInstance(Locale inLocale) 

Source Link

Document

Returns a currency format for the specified locale.

Usage

From source file:org.mifos.platform.accounting.service.AccountingDataCacheManager.java

private String parseNumber(String number) {
    // FIXME should use this from common util
    StringBuilder pattern = new StringBuilder();
    DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getCurrencyInstance(Locale.ENGLISH);
    for (Short i = 0; i < DIGITS_BEFORE_DECIMAL; i++) {
        pattern.append('#');
    }//from w  ww .j  a  v  a 2 s.c  o m
    pattern.append(decimalFormat.getDecimalFormatSymbols().getDecimalSeparator());
    for (short i = 0; i < getDigitsAfterDecimal(); i++) {
        pattern.append('#');
    }
    decimalFormat.applyLocalizedPattern(pattern.toString());
    decimalFormat.setDecimalSeparatorAlwaysShown(false);
    decimalFormat.setMinimumFractionDigits(getDigitsAfterDecimal());
    return decimalFormat.format(Double.parseDouble(number));
}