String d="0xD437D437";
System.out.println(Integer.decode(d));
The docs state
This sequence of characters must represent a positive value or a NumberFormatException will be thrown.
But 0xD437D437
is a negative value, namely -734538697
, as can be seen by Integer.toHexString(-734538697)
resulting in "d437d437"
.
Therefore either parse it as a Long
as @Bonniu says if you are looking for a positive value or if you are actually trying to parse a negative int you could just convert the resulting Long
back into an Integer
/ int
:
Long.decode("0xD437D437").intValue() // -734538697