Created
January 29, 2011 13:49
-
-
Save NIA/801844 to your computer and use it in GitHub Desktop.
parse JSON double to Double (null allowed), catching optional NumberFormatException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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