Java examples for java.lang:double Format
to Decimal Format String as 0.###
//package com.java2s; import java.text.DecimalFormat; public class Main { public static void main(String[] argv) { double doubleVal = 42.45678; System.out.println(toDecimalFormatString(doubleVal)); }/* w ww.j av a 2 s . co m*/ public static String toDecimalFormatString(double doubleVal) { DecimalFormat df = new DecimalFormat("0.###"); return df.format(doubleVal); } }