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.


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

import java.math.BigDecimal;

public class Main {

    public static void main(String[] args) {

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

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

%d bloggers like this: