Skip to content

Instantly share code, notes, and snippets.

@NIA
Created January 29, 2011 13:49
Show Gist options
  • Save NIA/801844 to your computer and use it in GitHub Desktop.
Save NIA/801844 to your computer and use it in GitHub Desktop.
parse JSON double to Double (null allowed), catching optional NumberFormatException
public static Double parseDouble(String string) throws ParseException {
if("null".equals(string)) {
return null;
}
try {
return Double.parseDouble(string);
} catch (NumberFormatException e) {
throw new ParseException("Unparseable double: " + string, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment