Java Convert Octal String to Long

Tags: Octal long

In this Java core tutorial we learn how to convert an octal String into long value in Java programming language.

How to convert Octal String to Long in Java

In Java, with a given octal String we can use the Long.decode(String nm) static method to convert it to a long value as the following example Java code.

ConvertOctalToLongExample.java

public class ConvertOctalToLongExample {
    public static void main(String... args) {
        String octalValue1 = "0246000"; // String start with 0

        // Convert Octal String to Long
        long longValue1 = Long.decode(octalValue1);

        System.out.println("Octal value: " + octalValue1);
        System.out.println("Long value: " + longValue1);
    }
}
The output as below.
Octal value: 0246000
Long value: 84992

Happy Coding 😊

Java Convert Long to Hexadecimal String

Java Convert Hexadecimal String to Long

Java Convert Long to Octal String

Java Convert long to byte