Skip to content

Commit

Permalink
move stringIsParsableInteger from ERXExtensions to ERXStringUtilities
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed May 1, 2012
1 parent 0168864 commit d74b7d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ public static boolean safeDifferent(Object v1, Object v2) {
* an integer.
* @param s string to be parsed
* @return if the string can be parsed into an int
* @deprecated use {@link ERXStringUtilities#stringIsParseableInteger(String)}
*/
// FIXME: Should return false if the object is null.
// MOVEME: ERXStringUtilities
@Deprecated
public static boolean stringIsParseableInteger(String s) {
try {
Integer.parseInt(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,22 @@ public static Integer integerWithString(String s) {
return null;
}

/**
* Tests if a given string object can be parsed into
* an integer.
* @param s string to be parsed
* @return <code>true</code> if the string is not <code>null</code>
* and can be parsed to an int
*/
public static boolean stringIsParseableInteger(String s) {
try {
Integer.parseInt(s);
return true;
} catch (NumberFormatException e) {
return false;
}
}

/**
* Wrapper for {@link Integer#valueOf(String)} that catches
* the NumberFormatException.
Expand Down

0 comments on commit d74b7d9

Please sign in to comment.