Java – How to create BigDecimal from long datatype value ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

Problem Statement

You need to create BigDecimal values from long type value in your Java program.

Solution

Use BigDecimal.valueOf method to create BigDecimal from the long value.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book
import java.math.BigDecimal;

public class Main {

    public static void main(String[] args) {

        System.out.println("Abundantcode.com Java Tutorials");
        long lng = 19866;

        BigDecimal input = BigDecimal.valueOf(lng);
        System.out.println("Using BigDecimal.valueOf " + input);

    }
}
%d bloggers like this: