Java Fraction Format formatDecimal(double value, String mask)

Here you can find the source of formatDecimal(double value, String mask)

Description

Formata um decimal, de acordo com a mascara.

License

Open Source License

Parameter

Parameter Description
value a parameter
mask a parameter

Declaration

public static String formatDecimal(double value, String mask) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class Main {
    /**// w  w w .  ja  v  a 2s .c  om
     * Formata um decimal, de acordo com a mascara.
     * @param value
     * @param mask
     * @return
     */
    public static String formatDecimal(double value, String mask) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        dfs.setDecimalSeparator(',');
        dfs.setGroupingSeparator('.');

        DecimalFormat df = new DecimalFormat(mask, dfs);
        return df.format(value);
    }
}

Related

  1. formatDecimal(double number)
  2. formatDecimal(double numToFormat)
  3. formatDecimal(double value)
  4. formatDecimal(double value, int maxFractionDigits1, int maxFractionDigits2)
  5. formatDecimal(double value, int precision)
  6. formatDecimal(String format, double value)
  7. formatDecimals(double d, int mantissa)
  8. formatDecimals(double number)
  9. formatDecNumber(Double number, String pattern)