Here you can find the source of getFormattedNumber(Double number, int decimals, Locale locale)
public static String getFormattedNumber(Double number, int decimals, Locale locale)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; import java.util.Locale; public class Main { public static String getFormattedNumber(Double number, int decimals, Locale locale) {//from w ww . ja va2s . c o m NumberFormat nf = NumberFormat.getInstance(locale); nf.setMaximumFractionDigits(decimals); nf.setMinimumFractionDigits(decimals); return nf.format(number); } }