Skip to content

Instantly share code, notes, and snippets.

@lobster1234
Created March 25, 2011 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobster1234/886633 to your computer and use it in GitHub Desktop.
Save lobster1234/886633 to your computer and use it in GitHub Desktop.
Apache StringUtils isNumeric() fails for strings that have numbers with a period or negative value. Here is a simple fix to handle it.
String string = "-12.49";
boolean isNumeric = string!=null && string.length() > 0 && string.toUpperCase().equals(string.toLowerCase());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment