Here you can find the source of NumberFormat(double str, int max, int min)
public static String NumberFormat(double str, int max, int min)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String NumberFormat(double str, int max, int min) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(max); nf.setMinimumFractionDigits(min); return nf.format(str); }/*from w w w.j a v a 2 s . c om*/ }