Java Fraction Format formatDoubleAmount(double amount)

Here you can find the source of formatDoubleAmount(double amount)

Description

Formats the given double as a dollar amount, with negative amounts in parentheses.

License

Apache License

Parameter

Parameter Description
amount Amount to render as formatted String

Return

Formatted String

Declaration

public static String formatDoubleAmount(double amount) 

Method Source Code

//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);
    }
}

Related

  1. formatDouble(double value)
  2. formatDouble(double value, int precision)
  3. FormatDouble(final double dblValue, final int iNumLeft, final int iNumRight, final double dblMultiplier)
  4. formatDouble(Object obj)
  5. formatDouble(Object value)
  6. formatDoubleArray(double[] arr, String format)
  7. formatDoubleAsPointsString(Double d)
  8. formatDoubleAsString(Double val)
  9. formatDoubleDecimal(float in)