I'm working on some code in Robolectric, namely IntegerResourceLoader
. The following method is throwing a RuntimeException
when rawValue
is something such as 0xFFFF0000:
@Override
public Object convertRawValue( String rawValue ) {
try {
return Integer.parseInt( rawValue );
} catch ( NumberFormatException nfe ) {
throw new RuntimeException( rawValue + " is not an integer." );
}
}
I tried using Integer.decode(String) but that throws a NumberFormatException even though the grammar appears to be correct.
decode()
is the right method to call but it fails because 0xFFFF0000 is higher than 0x7fffffff max limit for integer. You may want to consider Long.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With