Here you can find the source of CreateDecimalFormat(int numberOfDecimalsDisplayed)
public static DecimalFormat CreateDecimalFormat(int numberOfDecimalsDisplayed)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { /**//from w ww. j a v a 2 s. com * Gets the amount of decimals that should be displayed with a DecimalFormat object. * @return */ public static DecimalFormat CreateDecimalFormat(int numberOfDecimalsDisplayed) { if (numberOfDecimalsDisplayed < 1) return new DecimalFormat("#"); String format = "#."; for (int i = 1; i <= numberOfDecimalsDisplayed; i++) format += "#"; return new DecimalFormat(format); } }