NumberUtil { public static boolean isNumber(@Nullable String str) { return NumberUtils.isCreatable(str); }  static byte[] toBytes(int value); static byte[] toBytes(long value); static byte[] toBytes(double val); static int toInt(byte[] bytes); static long toLong(byte[] bytes); static double toDouble(byte[] bytes); static boolean isNumber(@Nullable String str); static boolean isHexNumber(@Nullable String value); static int toInt(@NotNull String str); static int toInt(@Nullable String str, int defaultValue); static long toLong(@NotNull String str); static long toLong(@Nullable String str, long defaultValue); static double toDouble(@NotNull String str); static double toDouble(@Nullable String str, double defaultValue); static Integer toIntObject(@NotNull String str); static Integer toIntObject(@Nullable String str, Integer defaultValue); static Long toLongObject(@NotNull String str); static Long toLongObject(@Nullable String str, Long defaultValue); static Double toDoubleObject(@NotNull String str); static Double toDoubleObject(@Nullable String str, Double defaultValue); static Integer hexToIntObject(@NotNull String str); static Integer hexToIntObject(@Nullable String str, Integer defaultValue); static Long hexToLongObject(@NotNull String str); static Long hexToLongObject(@Nullable String str, Long defaultValue); static String toString(int i); static String toString(@NotNull Integer i); static String toString(long l); static String toString(@NotNull Long l); static String toString(double d); static String toString(@NotNull Double d); static String to2DigitString(double d); static int toInt32(long x);  }
@Test public void isNumber() { assertThat(NumberUtil.isNumber("123")).isTrue(); assertThat(NumberUtil.isNumber("-123.1")).isTrue(); assertThat(NumberUtil.isNumber("-1a3.1")).isFalse(); assertThat(NumberUtil.isHexNumber("0x12F")).isTrue(); assertThat(NumberUtil.isHexNumber("-0x12A3")).isTrue(); assertThat(NumberUtil.isHexNumber("12A3")).isFalse(); }