Class NumberUtils


  • public class NumberUtils
    extends java.lang.Object
    Utility class for parsing strings into numbers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double parseDouble​(@NotNull java.lang.String s)
      Parses a double string.
      static int parseInt​(@NotNull java.lang.String s)
      Parses an integer string.
      static int parseInt​(@NotNull java.lang.String s, int defaultValue)
      Parses an integer string.
      static long parseLong​(@NotNull java.lang.String s)
      Parses a long string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • parseInt

        public static int parseInt​(@NotNull
                                   @NotNull java.lang.String s)
        Parses an integer string.
        Parameters:
        s - the string to parse
        Returns:
        the integer value or zero if value not readable
      • parseInt

        public static int parseInt​(@NotNull
                                   @NotNull java.lang.String s,
                                   int defaultValue)
        Parses an integer string.
        Parameters:
        s - the string to parse
        defaultValue - the default value
        Returns:
        the integer value or the default value if value not readable
      • parseLong

        public static long parseLong​(@NotNull
                                     @NotNull java.lang.String s)
        Parses a long string.
        Parameters:
        s - the string to parse
        Returns:
        the long value or zero if value not readable
      • parseDouble

        public static double parseDouble​(@NotNull
                                         @NotNull java.lang.String s)
        Parses a double string.
        Parameters:
        s - the string to parse
        Returns:
        the double value or zero if value not readable