Package com.jbstrap.core.converters
Class ObjectConverter
java.lang.Object
com.jbstrap.core.converters.ObjectConverter
- Since:
- 4.0
- Author:
- JBStrap
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
static <T> T
static Long
integerToLong
(Integer intVal) static BigDecimal
stringToBigDecimal
(String value) static Boolean
stringToBoolean
(String value) static Date
stringToDate
(String value, String pattern) static Double
stringToDouble
(String value) static Float
stringToFloat
(String value) static Integer
stringToInteger
(String value) static Long
stringToLong
(String value)
-
Method Details
-
convert
public static <T> T convert(Object from, Class<T> to) throws IllegalAccessException, InvocationTargetException - Type Parameters:
T
- The converted type- Parameters:
from
- The source object, that will be convertedto
- The class, to which the source object will be converted to- Returns:
- The converted value
- Throws:
InvocationTargetException
- If no converter method was implementedIllegalAccessException
- If no converter method was implemented
-
convert
public static <T> T convert(Object from, Class<T> to, String datePattern) throws IllegalAccessException, InvocationTargetException - Type Parameters:
T
- The converted type- Parameters:
from
- The source object, that will be convertedto
- The class, to which the source object will be converted todatePattern
- If a date is in the conversion, the date format- Returns:
- The converted value
- Throws:
InvocationTargetException
- If no converter method was implementedIllegalAccessException
- If no converter method was implemented
-
stringToBigDecimal
- Parameters:
value
- The string value- Returns:
- The big decimal value
-
stringToBoolean
- Parameters:
value
- The string value- Returns:
- The converted boolean value
-
stringToDate
- Parameters:
value
- The string valuepattern
- The date format- Returns:
- The converted date value
- Throws:
ParseException
- If the specified format cannot be applied to the string value
-
stringToLong
- Parameters:
value
- The string value- Returns:
- The Long value
-
stringToInteger
- Parameters:
value
- The string value- Returns:
- The Integer value
-
stringToDouble
- Parameters:
value
- The string value- Returns:
- The Double value
-
integerToLong
- Parameters:
intVal
- The Integer value- Returns:
- The Long value
-
stringToFloat
- Parameters:
value
- The string value- Returns:
- The float value
-