Class NumberConverter


  • public final class NumberConverter
    extends Object

    The NumberConvert is a final class that provide methods for converting numbers in String format to a Java's Primitive Data Type. This class currently support converting numbers in string representation to integer long and integer int values. This class utilized methods from other class in this package and should not be as fast as when calling other classes directly.

    Since:
    1.0.0.f
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int toInt​(String input)
      Parse a string of signed decimal value without a floating point value into an integer int value.
      static int toInt​(String input, int base)
      Parse the input string to an integer int value with the defined base number for the conversion.
      static long toLong​(String input)
      Parse a string of decimal value without a floating point value into an integer long value.
      static long toLong​(String input, int base)
      Parse the input string to an integer long value with the defined base number for the conversion.
    • Method Detail

      • toInt

        public static int toInt​(String input)
        Parse a string of signed decimal value without a floating point value into an integer int value. This method parses input as signed values. This method does not throw error. However, the Base10Util.toInt method that ultilizes by this method throws error.
        Parameters:
        input - A string to be parsed to an integer int value.
        Returns:
        An integer int value of the decimal input string.
        Since:
        1.0.0.f
        See Also:
        Base10Util.toInt(String)
      • toInt

        public static int toInt​(String input,
                                int base)
        Parse the input string to an integer int value with the defined base number for the conversion. Current support bases are 2, 3, 8, 10, 16. This method parses input as signed values. This method only throw UnsupportedOperationException. However, methods that ultilizes by this method throw errors.
        Parameters:
        input - A string to be parsed to an integer int value.
        base - An integer int value that defines the number base of the input string.
        Returns:
        An integer int value of the input string.
        Throws:
        UnsupportedOperationException - If the base is a value that is not supported.
        Since:
        1.0.0.f
        See Also:
        Base2Util.toInt(String), Base3Util.toInt(String), Base8Util.toInt(String), Base10Util.toInt(String), Base16Util.toInt(String)
      • toLong

        public static long toLong​(String input)
        Parse a string of decimal value without a floating point value into an integer long value. This method parses input as signed values. This method does not throw error. However, the Base10Util.toLong method that ultilizes by this method throws error.
        Parameters:
        input - A string to be parsed to an integer long value.
        Returns:
        An integer long value of the decimal input string.
        Since:
        1.0.0.f
        See Also:
        Base10Util.toLong(String)
      • toLong

        public static long toLong​(String input,
                                  int base)
        Parse the input string to an integer long value with the defined base number for the conversion. Current support bases are 2, 3, 8, 10, 16. This method parses input as signed values. This method only throws UnsupportedOperationException. However, methods that ultilizes by this method throw errors.
        Parameters:
        input - A string to be parsed to an integer long value.
        base - An integer int value that defines the number base of the input string.
        Returns:
        An integer long value of the input string.
        Throws:
        UnsupportedOperationException - If the base is a value that is not supported.
        Since:
        1.0.0.f
        See Also:
        Base2Util.toLong(String), Base3Util.toLong(String), Base8Util.toLong(String), Base10Util.toLong(String), Base16Util.toLong(String)