Here you can find the source of format(double number, int nums)
public static String format(double number, int nums)
//package com.java2s; public class Main { public static String format(double number, int nums) { // return new BigDecimal(number).setScale(nums, BigDecimal.ROUND_HALF_UP).doubleValue(); // return Double.valueOf(new DecimalFormat("#.00").format(number)); return String.format("%." + nums + "f", number); }/* ww w.ja v a 2 s.c o m*/ }