Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { static public String customNumberFormat(String pattern, double value) { DecimalFormat myFormatter = new DecimalFormat(pattern); String output = myFormatter.format(value); return output; } }