Here you can find the source of formatDouble(Double valor, int decimal)
Parameter | Description |
---|---|
valor | a parameter |
decimal | a parameter |
public static final String formatDouble(Double valor, int decimal)
//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); } }