Java BigDecimal from toBigDecimal(Double d)

Here you can find the source of toBigDecimal(Double d)

Description

Converts a Double to a BigDecimal.

License

Open Source License

Parameter

Parameter Description
The Double to be converted.

Return

The converted BigDecimal. Returns null when the input parameter is null.

Declaration

public static BigDecimal toBigDecimal(Double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2015 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from  w  w w . j  a v  a2s .c o  m
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.math.BigDecimal;

public class Main {
    /**
     * Converts a Double to a BigDecimal.
     *
     * @param The
     *          Double to be converted.
     * @return The converted BigDecimal. Returns <code>null</code> when the input parameter is <code>null</code>.
     */
    public static BigDecimal toBigDecimal(Double d) {
        if (d == null) {
            return null;
        }
        return BigDecimal.valueOf(d);
    }
}

Related

  1. numberToBigDecimal(Number value)
  2. numberToBigDecimal(Object number)
  3. numberToBigDecimal(Object obj)
  4. toBigDecimal(byte[] bytes)
  5. toBigDecimal(Double d)
  6. toBigDecimal(double val)
  7. toBigDecimal(double[][] a)
  8. toBigDecimal(final byte value)
  9. toBigDecimal(final Double d)