Java BigDecimal adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal)

Here you can find the source of adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal)

Description

Adjusts the BigDecimal from JCo value to the correct customized one.

License

Open Source License

Parameter

Parameter Description
value BigDecimal from JCO
decimal customized number of decimals

Return

corrected BigDecimal

Declaration

public static BigDecimal adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal) 

Method Source Code


//package com.java2s;
/*/*from   ww  w.j  a  v  a  2s  .c  o  m*/
 * [y] hybris Platform
 *
 * Copyright (c) 2000-2014 hybris AG
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of hybris
 * ("Confidential Information"). 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 hybris.
 *
 *
 */

import java.math.BigDecimal;

public class Main {
    /**
     * Adjusts the BigDecimal from JCo value to the correct customized one.<br>
     *
     * @param value
     *           BigDecimal from JCO
     * @param decimal
     *           customized number of decimals
     * @return corrected BigDecimal
     */
    public static BigDecimal adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal) {
        final long withoutDecimalPoint = value.unscaledValue().longValue();
        final BigDecimal newValue = BigDecimal.valueOf(withoutDecimalPoint, decimal);
        return newValue;
    }
}

Related

  1. areEqual(BigDecimal aThis, BigDecimal aThat)
  2. areEqual(BigDecimal first, BigDecimal second)
  3. asArray(final BigDecimal... elements)
  4. average(BigDecimal... values)