diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/helper/StringHelper.java b/li.strolch.utils/src/main/java/li/strolch/utils/helper/StringHelper.java index 38cff688c..8ccca61fa 100644 --- a/li.strolch.utils/src/main/java/li/strolch/utils/helper/StringHelper.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/helper/StringHelper.java @@ -711,6 +711,23 @@ public class StringHelper { return value != null && !value.isEmpty(); } + /** + * Checks if all characters in the string are digits + * + * @param value + * the value to check + * + * @return true if all characters are digits, false if not, i.e. a letter, special character or a minus, etc. + */ + public static boolean isAllDigits(String value) { + for (int i = 0; i < value.length(); i++) { + if (!Character.isDigit(value.charAt(i))) + return false; + } + + return true; + } + /** *

Parses the given string value to a boolean. This extends the default {@link Boolean#parseBoolean(String)} as * it throws an exception if the string value is not equal to "true" or "false" being case insensitive.