Java BigDecimal to bigDecimalToLong(BigDecimal bigDecimal)

Here you can find the source of bigDecimalToLong(BigDecimal bigDecimal)

Description

big Decimal To Long

License

Open Source License

Declaration

public static Long bigDecimalToLong(BigDecimal bigDecimal) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static final int DECIMAL_SCALE = 8;
    public static final RoundingMode ROUNDING_MODE = RoundingMode.HALF_UP;
    private static final BigDecimal SATOSHIS = new BigDecimal(100000000);

    public static Long bigDecimalToLong(BigDecimal bigDecimal) {
        bigDecimal.setScale(DECIMAL_SCALE, ROUNDING_MODE);
        return bigDecimal.multiply(SATOSHIS).longValue();
    }//from   w ww . j a va2  s.  co  m
}

Related

  1. bigDecimalToByte(BigDecimal num)
  2. bigDecimalToBytes(BigDecimal decimal)
  3. bigDecimalToDbString(BigDecimal bd)
  4. bigDecimalToInteger(BigDecimal value)
  5. bigDecimaltoJSONString(Object obj)
  6. bigDecimalToLong(BigDecimal value)
  7. bigDecimalToStellarBalance(final BigDecimal balance)
  8. bigDecimalToString(BigDecimal bigDecimal)
  9. bigDecimalToString(BigDecimal dec)