Here you can find the source of toLimitDecimalFloatStr(double number, int newScale)
public static String toLimitDecimalFloatStr(double number, int newScale)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String toLimitDecimalFloatStr(double number, int newScale) { NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(newScale); return nf.format(number); }//from ww w. j av a 2s . c o m }