Here you can find the source of prettyDecimalFormat(double d, int numPlaces)
public static String prettyDecimalFormat(double d, int numPlaces)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { public static String prettyDecimalFormat(double d, int numPlaces) { StringBuilder sb = new StringBuilder("#."); for (int i = 0; i < numPlaces; i++) { sb.append("#"); }/*from w w w . j ava2 s. c o m*/ DecimalFormat dFormat = new DecimalFormat(sb.toString()); return dFormat.format(d); } }