Class JKConversionUtil

java.lang.Object
com.jk.core.util.JKConversionUtil

public class JKConversionUtil extends Object
This class is a utility class used for performing various types of conversions.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    This method converts an object to a boolean value with false as default value.
    static boolean
    toBoolean(Object value, boolean defaultValue)
    This method converts an object to a boolean value, with a default value if conversion is not possible.
    static Date
    toDate(Object value)
    This method converts an object to a Date value with a default value of null.
    static Date
    toDate(Object value, Date defaultValue)
    This method converts an object to a date value, with a default value if conversion is not possible.
    static double
    This method converts an object to a double value with a default value of 0.
    static double
    toDouble(Object value, double defaultValue)
    This method converts an object to a double value, with a default value if conversion is not possible.
    static float
    toFloat(Object value)
    This method converts an object to a float value.
    static Integer
    This method converts an object to a integer value with a default value of 0.
    static int
    toInteger(Object value, int defaultValue)
    This method converts an object to a integer value, with a default value if conversion is not possible.
    static long
    toLong(Object value)
    This method converts an object to a long value with a default value of 0.
    static long
    toLong(Object value, long defaultValue)
    This method converts an object to a long value, with a default value if conversion is not possible.
    static String
    This method converts an object to a string value.
    static Time
    toTime(Object value)
    This method converts an object to a Time value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKConversionUtil

      public JKConversionUtil()
  • Method Details

    • toBoolean

      public static boolean toBoolean(Object value)
      This method converts an object to a boolean value with false as default value.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted boolean value.
    • toDate

      public static Date toDate(Object value)
      This method converts an object to a Date value with a default value of null.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted Date value.
    • toDouble

      public static double toDouble(Object value)
      This method converts an object to a double value with a default value of 0.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted double value.
    • toFloat

      public static float toFloat(Object value)
      This method converts an object to a float value.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted float value.
    • toInteger

      public static Integer toInteger(Object value)
      This method converts an object to a integer value with a default value of 0.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted integer value.
    • toString

      public static String toString(Object value)
      This method converts an object to a string value.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted string value.
    • toTime

      public static Time toTime(Object value)
      This method converts an object to a Time value.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      The converted Time value, or null if the conversion is not possible.
    • toBoolean

      public static boolean toBoolean(Object value, boolean defaultValue)
      This method converts an object to a boolean value, with a default value if conversion is not possible.
      Parameters:
      value - Specifies the value to be converted.
      defaultValue - Specifies the default value to be returned if conversion is not possible.
      Returns:
      the converted boolean value, or the default value if conversion is not possible.
    • toDouble

      public static double toDouble(Object value, double defaultValue)
      This method converts an object to a double value, with a default value if conversion is not possible.
      Parameters:
      value - Specifies the value to be converted.
      defaultValue - Specifies the default value to be returned if conversion is not possible.
      Returns:
      the converted double value, or the default value if conversion is not possible.
    • toInteger

      public static int toInteger(Object value, int defaultValue)
      This method converts an object to a integer value, with a default value if conversion is not possible.
      Parameters:
      value - Specifies the value to be converted.
      defaultValue - Specifies the default value to be returned if conversion is not possible.
      Returns:
      the converted integer value, or the default value if conversion is not possible.
    • toLong

      public static long toLong(Object value)
      This method converts an object to a long value with a default value of 0.
      Parameters:
      value - Specifies the value to be converted.
      Returns:
      the converted long value.
    • toLong

      public static long toLong(Object value, long defaultValue)
      This method converts an object to a long value, with a default value if conversion is not possible.
      Parameters:
      value - Specifies the value to be converted.
      defaultValue - Specifies the default value to be returned if conversion is not possible.
      Returns:
      the converted long value, or the default value if conversion is not possible.
    • toDate

      public static Date toDate(Object value, Date defaultValue)
      This method converts an object to a date value, with a default value if conversion is not possible.
      Parameters:
      value - Specifies the value to be converted.
      defaultValue - Specifies the default value to be returned if conversion is not possible.
      Returns:
      the converted date value, or the default value if conversion is not possible.