0

I have facing Problem in Parsing 16 digit hex string to decimal integer value.

I have tried following code for converting hex to decimal:

    String HexString= "0000113fc208dff"; 
    int dec= Long.parseLong(HexString);

But its throwing NumberFormatException: Invalid int ...

Now How do i Convert to Decimal/Binary and Further Convert Decimal/Binary to Time Stamp ??

Any help would be appreciated.

Amy
  • 4,034
  • 1
  • 20
  • 34
Manish Goswami
  • 863
  • 10
  • 27

2 Answers2

3

The first parameter is the String, second parameter is the radix

long epoch=Long.parseLong(str, 16);

Then convert to Timestamp through Calendar

Calendar c=Calendar.getInstance();
c.setTimeInMillis(epoch);
Patrick Chan
  • 1,019
  • 10
  • 14
2

try this code

String HexString= "0000113fc208dff"; 
long dec= Long.parseLong(HexString, 16);
System.out.println(dec);

Result:

1185345998335  
Scary Wombat
  • 44,617
  • 6
  • 35
  • 64