1 package net.pterodactylus.sone.utils;
3 import javax.annotation.Nullable;
5 import com.google.common.primitives.Ints;
6 import com.google.common.primitives.Longs;
9 * Parses numbers from strings.
11 public class NumberParsers {
14 public static Integer parseInt(@Nullable String text,
15 @Nullable Integer defaultValue) {
19 Integer value = Ints.tryParse(text);
20 return (value == null) ? defaultValue : value;
24 public static Long parseLong(@Nullable String text,
25 @Nullable Long defaultValue) {
29 Long value = Longs.tryParse(text);
30 return (value == null) ? defaultValue : value;