Java BigDecimal Format formatBigDecimal(BigDecimal d)

Here you can find the source of formatBigDecimal(BigDecimal d)

Description

Method for adding trailing zeroes for a BigDecimal value

License

Open Source License

Parameter

Parameter Description
BigDecimal a parameter

Return

String

Declaration

public static String formatBigDecimal(BigDecimal d) 

Method Source Code

//package com.java2s;
/*/*from  w w  w . j a  v a2  s. c o  m*/
 * @(#)ConversionUtil.java
 *
 * Copyright by ObjectFrontier, Inc.,
 * 12225 Broadleaf Lane, Alpharetta, GA 30005, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of ObjectFrontier, Inc. You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of
 * the license agreement you entered into with ObjectFrontier.
 */

import java.math.BigDecimal;

import java.text.DecimalFormat;

public class Main {
    /**
     * Method for adding trailing zeroes for a BigDecimal value
     * @param BigDecimal
     * @return String 
     */
    public static String formatBigDecimal(BigDecimal d) {
        DecimalFormat df = new DecimalFormat("#.##");
        df.setMinimumFractionDigits(2);
        return df.format(d);
    }
}

Related

  1. formatAsReadable(BigDecimal number)
  2. formatBetrag(BigDecimal bdBetrag, Locale locale)
  3. formatBigDecimal(BigDecimal bd, NumberFormat format)
  4. formatBigDecimal(BigDecimal bigDecimal)
  5. formatBigDecimal(BigDecimal bigDecimal, int scale)
  6. formatBigDecimal(BigDecimal n, int dp)
  7. formatBigDecimal(BigDecimal number, int val)
  8. formatBigDecimal(BigDecimal valor, int decimal)
  9. formatBigDecimal(BigDecimal value, char thousandSep, char decimalPoint, int numDecimals)