multiply two BigDecimal - Java java.math

Java examples for java.math:BigDecimal Calculation

Description

multiply two BigDecimal

Demo Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] argv) throws Exception {
        BigDecimal amount = new BigDecimal("1234");
        BigDecimal multiplicand = new BigDecimal("1234");
        System.out.println(multiply(amount, multiplicand));
    }//w  w w .j av  a 2s.com

    /**
     * ?
     * 
     * @param amount
     * @param multiplicand
     * @return
     */
    public static BigDecimal multiply(BigDecimal amount,
            BigDecimal multiplicand) {
        BigDecimal result = new BigDecimal("0.00");
        if (amount != null && multiplicand != null) {
            result = amount.multiply(multiplicand);
        }
        return result;
    }
}

Related Tutorials