Java examples for java.math:BigDecimal Format
format Currency via BigDecimal
//package com.java2s; import java.math.BigDecimal; import java.text.DecimalFormat; public class Main { public static void main(String[] argv) throws Exception { BigDecimal cash = new BigDecimal("1234"); System.out.println(formatCurrency(cash)); }//from ww w . j a v a 2 s.c om public static String formatCurrency(BigDecimal cash) { DecimalFormat df = (DecimalFormat) DecimalFormat .getNumberInstance(); df.setMinimumIntegerDigits(1); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); return df.format(cash); } }