| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.util.Conversion |
Utility methods for safe conversions of string or boxed representations of numbers, to numbers.
By default, it is assumed that the string represents a number in base 10. The exceptions are:
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Conversion() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static int |
stringToInt(String s, int def)
Convert to integer.
| ||||||||||
| static int |
stringToInt(String s)
Convert to long with a default value of zero.
| ||||||||||
| static long |
stringToLong(String s, long def)
Convert to long.
| ||||||||||
| static long |
stringToLong(String s)
Convert to long with a default value of zero.
| ||||||||||
| static int |
toInt(Object o, int def)
Best effort conversion of an object to an integer.
| ||||||||||
| static int |
toInt(Object o)
Best effort conversion of an object to an integer.
| ||||||||||
| static long |
toLong(Object o)
Best effort conversion of an object to an integer.
| ||||||||||
| static long |
toLong(Object o, long def)
Best effort conversion of an object to a long.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Convert to integer.
| s | input string |
|---|---|
| def | the default value |
Convert to long with a default value of zero.
| s | input string |
|---|
Convert to long.
| s | input string |
|---|---|
| def | the default value |
Convert to long with a default value of zero.
| s | input string |
|---|
Best effort conversion of an object to an integer.
| o | a String or an Integer |
|---|---|
| def | default value to return if the conversion fails |
Best effort conversion of an object to an integer. If the conversion fails, the value returned is 0.
| o | a String or an Integer |
|---|
Best effort conversion of an object to an integer. If the conversion fails, the value returned is 0.
| o | a String or an Long |
|---|
Best effort conversion of an object to a long.
| o | a String or an Long |
|---|---|
| def | default value to return if the conversion fails |