diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java index b5cfbfb5d2af..68e3113c3d5d 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java @@ -275,4 +275,17 @@ public static int stringToInt(String s, int defaultValue) { return defaultValue; } } + + public static long stringToLong(String s) { + return stringToLong(s, 0L); + } + public static long stringToLong(String s, long defaultValue) { + if (s == null) + return defaultValue; + try { + return Long.valueOf(s); + } catch (NumberFormatException e) { + return defaultValue; + } + } }