Here you can find the source of formatCurrency(String currency)
Parameter | Description |
---|---|
currency | a parameter |
public static String formatCurrency(String currency)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; import java.util.Locale; public class Main { /**//from w w w . j a va 2s . c om * currency fomate * * @param currency * @return */ public static String formatCurrency(String currency) { if ((null == currency) || "".equals(currency) || "null".equals(currency)) { return ""; } NumberFormat usFormat = NumberFormat.getCurrencyInstance(Locale.CHINA); try { return usFormat.format(Double.parseDouble(currency)); } catch (Exception e) { return ""; } } }