Here you can find the source of formatAsCurrency(Number amount)
Parameter | Description |
---|---|
amount | Currency amount |
public static String formatAsCurrency(Number amount)
//package com.java2s; import java.text.Format; import java.text.NumberFormat; public class Main { private static ThreadLocal<Format> CURRENCY_FORMAT = new ThreadLocal<Format>() { @Override/*from ww w.j a va 2 s . c o m*/ protected Format initialValue() { return NumberFormat.getCurrencyInstance(); } }; /** * Convenience method for converting {@link Number} to currency string * representation with minimal overhead. * * <p> * Intended for use in KRAD SpEL expressions, for example: * </p> * * <pre> * @{T(org.kuali.ole.krad.OleComponentUtils).formatAsCurrency(anAmount)} * </pre> * * @param amount * Currency amount * @return formatted currency string */ public static String formatAsCurrency(Number amount) { return amount == null ? "" : CURRENCY_FORMAT.get().format(amount); } }