Java Convert Byte to BigDecimal

Tags: byte BigDecimal

In this Java core tutorial we learn how to convert a byte value into a BigDecimal value in Java programming language.

How to convert byte to BigDecimal in Java

In Java, with a given byte value we can use the BigDecimal.valueOf(long val) static method to convert it to a BigDecimal value as the following Java program.

ConvertByteToBigDecimalExample.java

import java.math.BigDecimal;

public class ConvertByteToBigDecimalExample {
    public static void main(String... args) {
        byte byteValue = 12;

        // Convert Byte to BigDecimal
        BigDecimal bigDecimalValue = BigDecimal.valueOf(byteValue);

        System.out.println("byte value: " + byteValue);
        System.out.println("BigDecimal value: " + bigDecimalValue);
    }
}
The output as below.
byte value: 12
BigDecimal value: 12

Happy Coding 😊

Java Convert Byte to Hexadecimal String

Java Convert Hexadecimal String to Byte

Java Convert Byte to Octal String

Java Convert Octal String to Byte

Java Convert Byte to BigInteger