Java examples for java.lang:double Format
format double value as Currency
//package com.java2s; import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { public static void main(String[] argv) throws Exception { double val = 2.45678; System.out.println(formatCurrency(val)); }/* w ww . j av a 2 s.c o m*/ private static final NumberFormat df = DecimalFormat .getCurrencyInstance(); public static String formatCurrency(Double val) { if (val == null) return ""; else return df.format(val); } }