Here you can find the source of format(double value, int digits)
public static double format(double value, int digits)
//package com.java2s; //License from project: Apache License public class Main { public static double format(double value, int digits) { if (digits < 0) { return value; }/*from w w w.ja v a 2 s . c o m*/ return Double.valueOf(String.format("%." + digits + "f", value)); } }