Format Currency : Currency « Data Type « Java






Format Currency

       


import java.text.NumberFormat;

public class FormatUtils {

  public static String formatCurrency(Object value) {
    NumberFormat m_currencyformat = NumberFormat.getCurrencyInstance();
    return m_currencyformat.format(((Number) value).doubleValue());
  }

  public static String formatDouble(Object value) {
    NumberFormat doubleFormat = NumberFormat.getNumberInstance();

    return doubleFormat.format(((Number) value).doubleValue());
  }
}

   
    
    
    
    
    
    
  








Related examples in the same category

1.Getting Currency Symbols for Locale.US
2.Getting Currency Symbols for Locale.UK
3.Getting Currency Symbols for Locale.FRANCE
4.Get currency symbol
5.Use java.text.NumberFormat to format a currency value.
6.Money type