public final class NumberMethods extends NumberUtils
commons-lang3
's NumberUtils
class. Utility methods from NumberUtils
can be used as one-liners through this class.BYTE_MINUS_ONE, BYTE_ONE, BYTE_ZERO, DOUBLE_MINUS_ONE, DOUBLE_ONE, DOUBLE_ZERO, FLOAT_MINUS_ONE, FLOAT_ONE, FLOAT_ZERO, INTEGER_MINUS_ONE, INTEGER_ONE, INTEGER_ZERO, LONG_MINUS_ONE, LONG_ONE, LONG_ZERO, SHORT_MINUS_ONE, SHORT_ONE, SHORT_ZERO
Modifier and Type | Method and Description |
---|---|
static String |
format(Double input,
String format)
Format a double value.
|
static String |
format(Float input,
String format)
Format a float.
|
static String |
format(Integer input,
String format)
Format an integer.
|
static String |
format(Long input,
String format)
Format a long value.
|
static String |
format(Short input,
String format)
Format a short value.
|
static Integer |
toInteger(Object object)
|
static Long |
toLong(Object object)
|
compare, compare, compare, compare, createBigDecimal, createBigInteger, createDouble, createFloat, createInteger, createLong, createNumber, isCreatable, isDigits, isNumber, isParsable, max, max, max, max, max, max, max, max, max, max, max, max, min, min, min, min, min, min, min, min, min, min, min, min, toByte, toByte, toDouble, toDouble, toFloat, toFloat, toInt, toInt, toLong, toLong, toShort, toShort
public static Integer toInteger(Object object)
Integer
value of an Object
.
This method can infer the equivalent Integer
value of object
if:
object
is an instance of String
made up of numeric charactersobject
is an instance of Integer
object
- object to convertInteger
value of object
public static Long toLong(Object object)
Long
value of an Object
.
This method can infer the equivalent Long
value of object
if:
object
is an instance of String
made up of numeric charactersobject
is an instance of Long
object
- object to convertLong
value of object
public static String format(Integer input, String format)
input
- the number to formatformat
- the format to applypublic static String format(Long input, String format)
input
- the number to formatformat
- the format to applypublic static String format(Short input, String format)
input
- the number to formatformat
- the format to applypublic static String format(Float input, String format)
input
- the number to formatformat
- the format to applyCopyright © 2020. All rights reserved.