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> Tstatic <T> Tstatic LongintegerToLong(Integer intVal) static BigDecimalstringToBigDecimal(String value) static BooleanstringToBoolean(String value) static DatestringToDate(String value, String pattern) static DoublestringToDouble(String value) static FloatstringToFloat(String value) static IntegerstringToInteger(String value) static LongstringToLong(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
-