Numbers

org.beangle.commons.lang.Numbers
object Numbers

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Numbers.type

Members list

Value members

Concrete methods

def convert2BigDecimal(str: String, defaultValue: BigDecimal): BigDecimal
def convert2BigInt(str: String, defaultValue: BigInteger): BigInteger
def convert2Double(str: String, defaultValue: Double): Double
def convert2Float(str: String, defaultValue: Float): Float
def convert2Int(str: String, defaultValue: Integer): Integer
def convert2Long(str: String, defaultValue: Long): Long
def convert2Short(str: String, defaultValue: Short): Short
def isDigits(str: String): Boolean

Checks whether the String contains only digit characters.

Checks whether the String contains only digit characters.

Null and empty String will return false.

Value parameters

str

the String to check

Attributes

Returns

true if str contains only Unicode numeric

def toDouble(str: String, defaultValue: Double): Double
def toFloat(str: String, defaultValue: Float): Float
def toInt(str: String, defaultValue: Int): Int

Convert a String to an int, returning a default value if the conversion fails.

Convert a String to an int, returning a default value if the conversion fails.

If the string is null, the default value is returned.

toInt(null, 1) = 1
toInt("", 1)   = 1
toInt("1", 0)  = 1

Value parameters

defaultValue

the default value

str

the string to convert, may be null

Attributes

Returns

the int represented by the string, or the default if conversion fails

Since

3.0

def toInt(ids: Array[String]): Array[Int]

transform to int.

transform to int.

Value parameters

ids

an array of String objects.

Attributes

Returns

an array of int objects.

def toLong(str: String, defaultValue: Long): Long
def toLong(ids: Array[String]): Array[Long]

transformToLong.

transformToLong.

Value parameters

ids

an array of String objects.

Attributes

Returns

an array of Long objects.

def toShort(str: String, defaultValue: Short): Short