Here you can find the source of format(double num, String pattern)
public static String format(double num, String pattern)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static String format(double num, String pattern) { DecimalFormat doubleFormat = new DecimalFormat(pattern); String resultStr = doubleFormat.format(num); return resultStr; }//from w w w . ja v a 2s .co m }