Java Convert BigDecimal value into long value

Tags: BigDecimal Convert long

In this Java core tutorial we learn how to convert a java.math.BigDecimal object to a long value in Java programming language.

How to convert BigDecimal to long in Java

In Java, with a given BigDecimal object we can use the java.math.BigDecimal.longValue() method to convert it to a long value as the following example Java code.

BigDecimalLongValueExamples.java

package simplesolution.dev;

import java.math.BigDecimal;

public class BigDecimalLongValueExamples {

    public static void main(String... args) {
        BigDecimal bigDecimal = new BigDecimal("999999999.01");

        long longValue = bigDecimal.longValue();

        System.out.println(bigDecimal);
        System.out.println(longValue);
    }
}

Happy Coding 😊

Java Convert long to BigDecimal

Java Convert int to BigDecimal

Java Convert double to BigDecimal

Java Convert float to BigDecimal

Java Convert BigInteger to BigDecimal

How to use BigDecimal in Java by Examples

How to Add two BigDecimal values in Java

How to Subtract two BigDecimal values in Java

How to Multiply two BigDecimal values in Java

How to Divide two BigDecimal values in Java

Java Convert BigDecimal value into double value

Java Convert BigDecimal value into float value

Java Convert BigDecimal value into int value

Java Convert BigDecimal value into short value

Java Convert BigDecimal value to byte value

Java Convert BigDecimal to String

Java Convert String to BigDecimal

Java Compare two BigDecimal values

How to Negate BigDecimal Value in Java

How to Round BigDecimal Value in Java

How to Get Absolute of BigDecimal Value in Java

Java Convert BigDecimal to BigInteger