Class NumberConverter


  • public final class NumberConverter
    extends Object
    Utility class for numeric conversions
    • Method Detail

      • toLong

        public static Long toLong​(Object value)
        Converts object to long
        Parameters:
        value - Object to convert
        Returns:
        Long instance
      • toDouble

        public static Double toDouble​(Object value)
        Converts object to double
        Parameters:
        value - Object to convert
        Returns:
        Double instance
      • narrow

        public static <R> R narrow​(BigDecimal bigDecimal)
        Converts BigDecimal to the strictest numeric type available in following order: Integer, Long, Double, BigDecimal
        Type Parameters:
        R - Return parameter value
        Parameters:
        bigDecimal - BigDecimal instance
        Returns:
        Converted value
      • narrow

        public static Number narrow​(Number number)
        Converts Number to the strictest numeric type available in following order: Integer, Long, Double, BigDecimal
        Parameters:
        number - Number instance
        Returns:
        Converted value
      • isNumber

        public static boolean isNumber​(String source)
        Checks if string is a number
        Parameters:
        source - String to check
        Returns:
        True or false