I have:
int number = 0x00000024;
And it have no problems, but now im get it from with de format:
<MAN>
<NAME hexa="0x00000001"/>
</MAN>
And I try to parse hexa with:
Integer.parseInt(parser.getAttributeValue(0), 16)
But it says:
Unable to parse '0x00000001' as integer
Anyone knows whats happening?
Remove the 0x
:
Integer.parseInt(parser.getAttributeValue(0).substring(2), 16)
Building on the answer in How to convert a hexadecimal string to long in java?, you want:
int num = Long.decode(parser.getAttributeValue(0)).intValue();
User contributions licensed under CC BY-SA 3.0