Here you can find the source of formatDoubleAmount(double amount)
Parameter | Description |
---|---|
amount | Amount to render as formatted String |
public static String formatDoubleAmount(double amount)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { /**/* w w w . j a v a 2s . c om*/ * Formats the given double as a dollar amount, with negative amounts in parentheses. * @param amount Amount to render as formatted String * @return Formatted String */ public static String formatDoubleAmount(double amount) { NumberFormat formatter = new DecimalFormat("$#,###,##0.00;($#,###,##0.00)"); return formatter.format(amount); } }