Here you can find the source of formatCurrency(Number currencyValue)
Parameter | Description |
---|---|
currencyValue | a parameter |
public static String formatCurrency(Number currencyValue)
//package com.java2s; import java.text.NumberFormat; public class Main { /**/*from ww w . java 2 s.co m*/ * Method formatCurrency. Return currency value as string. * * @param currencyValue * @return String */ public static String formatCurrency(Number currencyValue) { if (currencyValue == null) return ""; if (currencyValue.doubleValue() == currencyValue.longValue()) return "" + currencyValue.longValue(); else { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); return nf.format(currencyValue); } } }