Reputation: 865
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.
Upvotes: 0
Views: 2764
Reputation: 44854
try this code
String HexString= "0000113fc208dff";
long dec= Long.parseLong(HexString, 16);
System.out.println(dec);
Result:
1185345998335
Upvotes: 2
Reputation: 1029
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);
Upvotes: 3