Class ObjectConverter

java.lang.Object
com.jbstrap.core.converters.ObjectConverter

public final class ObjectConverter extends Object
Since:
4.0
Author:
JBStrap
  • 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 converted
      to - The class, to which the source object will be converted to
      Returns:
      The converted value
      Throws:
      InvocationTargetException - If no converter method was implemented
      IllegalAccessException - 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 converted
      to - The class, to which the source object will be converted to
      datePattern - If a date is in the conversion, the date format
      Returns:
      The converted value
      Throws:
      InvocationTargetException - If no converter method was implemented
      IllegalAccessException - If no converter method was implemented
    • stringToBigDecimal

      public static BigDecimal stringToBigDecimal(String value)
      Parameters:
      value - The string value
      Returns:
      The big decimal value
    • stringToBoolean

      public static Boolean stringToBoolean(String value)
      Parameters:
      value - The string value
      Returns:
      The converted boolean value
    • stringToDate

      public static Date stringToDate(String value, String pattern) throws ParseException
      Parameters:
      value - The string value
      pattern - The date format
      Returns:
      The converted date value
      Throws:
      ParseException - If the specified format cannot be applied to the string value
    • stringToLong

      public static Long stringToLong(String value)
      Parameters:
      value - The string value
      Returns:
      The Long value
    • stringToInteger

      public static Integer stringToInteger(String value)
      Parameters:
      value - The string value
      Returns:
      The Integer value
    • stringToDouble

      public static Double stringToDouble(String value)
      Parameters:
      value - The string value
      Returns:
      The Double value
    • integerToLong

      public static Long integerToLong(Integer intVal)
      Parameters:
      intVal - The Integer value
      Returns:
      The Long value
    • stringToFloat

      public static Float stringToFloat(String value)
      Parameters:
      value - The string value
      Returns:
      The float value