Java examples for java.lang:double Format
double decimal format
//package com.java2s; import java.text.DecimalFormat; public class Main { public static Double decimal(double b, int scale) { String format = "%1$." + scale + "f"; DecimalFormat decimal = new DecimalFormat( String.format(format, 0.0)); return new Double(decimal.format(b)); }//from www . j a va 2 s . c om }