Sunday 26 May 2019

Java: Convert hexa string to long


'Long.parseLong' method converts hexa string to long value.

Example
String hexaString = "ff";
long number = Long.parseLong(hexaString, 16);

App.java
package com.sample.app;

public class App {

 public static void main(String args[]) {

  String hexaString = "ff";
  long number = Long.parseLong(hexaString, 16);

  System.out.println("hexaString : " + hexaString);
  System.out.println("number : " + number);

 }

}

Output
hexaString : ff
number : 255


You may like

No comments:

Post a Comment