Skip to content

Instantly share code, notes, and snippets.

@fty4
Created May 18, 2017 13:32
Show Gist options
  • Save fty4/ff3319a560512a509489e6a709df3d29 to your computer and use it in GitHub Desktop.
Save fty4/ff3319a560512a509489e6a709df3d29 to your computer and use it in GitHub Desktop.
/**
* Gibt an ob ein String ein Integer-Wert (Ganzzahl) darstellt
*
* @param p_str
* Zu pruefender String
* @return boolean-Wert
*/
private static boolean isInteger(String p_str) {
if (p_str == null)
return false;
else
return p_str.matches("^\\d*$");
}
// ODER
public static boolean isInteger(String input) {
try {
Integer.parseInt(input);
return true;
} catch (Exception e) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment