Java Code Examples for java.text.DecimalFormat.getCurrencyInstance()

The following are Jave code examples for showing how to use getCurrencyInstance() of the java.text.DecimalFormat class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Android-FilterView   File:   Source Code and License Vote up 5 votes
 * If user does not provide a valid locale it throws IllegalArgumentException.
 * If throws an IllegalArgumentException the locale sets to default locale
private void initSettings() {
    boolean success = false;
    while (!success) {
        try {
            fractionDigit = Currency.getInstance(locale).getDefaultFractionDigits();

            DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale);
            if (mGroupDivider > 0)
            groupDivider = symbols.getGroupingSeparator();

            if (mMonetaryDivider > 0)
            monetaryDivider = symbols.getMonetaryDecimalSeparator();

            currencySymbol = symbols.getCurrencySymbol();

            DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
            numberFormat = new DecimalFormat(df.toPattern(), symbols);

            success = true;
        } catch (IllegalArgumentException e) {
            Log.e(getClass().getCanonicalName(), e.getMessage());
            locale = getDefaultLocale();