Java Locale Format formatDouble(Double valor, int decimal)

Here you can find the source of formatDouble(Double valor, int decimal)

Description

Formata um Double

License

Open Source License

Parameter

Parameter Description
valor a parameter
decimal a parameter

Declaration

public static final String formatDouble(Double valor, int decimal) 

Method Source Code

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

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**//from   w w w . ja va  2 s  . c om
     * Formata um Double
     * @param valor
     * @param decimal
     * @return
     */
    public static final String formatDouble(Double valor, int decimal) {
        if (valor == null) {
            return null;
        }
        NumberFormat format = NumberFormat.getInstance(new Locale("pt", "BR"));
        format.setMaximumFractionDigits(decimal);
        format.setMinimumFractionDigits(decimal);
        return format.format(valor);
    }
}

Related

  1. formatDouble(double inVal, int inDecs)
  2. formatDouble(Double localDouble, int scale)
  3. formatDouble(double number)
  4. formatDouble(double v)
  5. formatDouble(double val, String format)
  6. formatDouble(double value)
  7. formatDouble(double value)
  8. formatDouble(final Double value)
  9. formatDouble(Locale locale, double value)