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,010
  • 1
  • 18
  • 34
Manish Goswami
  • 863
  • 9
  • 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,029
  • 10
  • 13
2

try this code

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

Result:

1185345998335  
Scary Wombat
  • 43,525
  • 5
  • 33
  • 63