public class DefaultConverter extends Object
Number
instances and String
representations of numbers
to their corresponding primitive types or wrapper classes. Conversion from types that are not supported
will result in a ConvertException
.Constructor and Description |
---|
DefaultConverter()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
static boolean |
convertTobool(Object obj)
Converts the given object to a
boolean . |
static Boolean |
convertToBool(Object obj)
Converts the given object to a
Boolean . |
static byte |
convertTobyte(Object obj)
Converts the given object to a
byte . |
static Byte |
convertToByte(Object obj)
Converts the given object to a
Byte . |
static char |
convertTochar(Object obj)
Converts the given object to a
char . |
static Character |
convertToChar(Object obj)
Converts the given object to a
Character . |
static double |
convertTodouble(Object obj)
Converts the given object to a
double . |
static Double |
convertToDouble(Object obj)
Converts the given object to a
Double . |
static float |
convertTofloat(Object obj)
Converts the given object to a
float . |
static Float |
convertToFloat(Object obj)
Converts the given object to a
Byte . |
static int |
convertToint(Object obj)
Converts the given object to an
int . |
static Integer |
convertToInt(Object obj)
Converts the given object to an
Integer . |
static long |
convertTolong(Object obj)
Converts the given object to a
long . |
static Long |
convertToLong(Object obj)
Converts the given object to a
Long . |
static short |
convertToshort(Object obj)
Converts the given object to a
short . |
static Short |
convertToShort(Object obj)
Converts the given object to a
short . |
public static int convertToint(Object obj)
int
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to an intpublic static Integer convertToInt(Object obj)
Integer
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to an Integerpublic static short convertToshort(Object obj)
short
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a shortpublic static Short convertToShort(Object obj)
short
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a shortpublic static long convertTolong(Object obj)
long
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a longpublic static Long convertToLong(Object obj)
Long
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a Longpublic static byte convertTobyte(Object obj)
byte
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a bytepublic static Byte convertToByte(Object obj)
Byte
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a Bytepublic static float convertTofloat(Object obj)
float
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a floatpublic static Float convertToFloat(Object obj)
Byte
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a Bytepublic static double convertTodouble(Object obj)
double
.obj
- the object to convertnull
ConvertException
- if the object cannot be converted to a doublepublic static Double convertToDouble(Object obj)
Double
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a Doublepublic static char convertTochar(Object obj)
char
.obj
- the object to convertnull
or the string is emptyConvertException
- if the object cannot be converted to a charpublic static Character convertToChar(Object obj)
Character
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a Characterpublic static boolean convertTobool(Object obj)
boolean
.obj
- the object to convertnull
or represents the numeric value 0ConvertException
- if the object cannot be converted to a booleanpublic static Boolean convertToBool(Object obj)
Boolean
.obj
- the object to convertnull
if the object is null
ConvertException
- if the object cannot be converted to a BooleanCopyright © 2025 Chemouni Uriel. All rights reserved.