Here you can find the source of format(double val)
public static String format(double val)
//package com.java2s; import java.text.*; public class Main { private static DecimalFormat df; /**// w ww .ja va 2 s . co m * Format decimals to 4 digits only */ public static String format(double val) { return new String(df.format(val)); } }