Package rife.tools
Class Convert
java.lang.Object
rife.tools.Convert
General purpose class providing methods to convert between data types.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
fromString
(String string, Class<?> type) Converts the given string into an object of specified type.static <T> T
getDefaultValue
(Class<T> clazz) Returns the default value of a given class.static boolean
Converts the specified object to a boolean value.static boolean
Converts the specified object to a boolean value; returns the default value if the conversion fails.static byte
Converts the specified object to a byte value.static byte
Converts the specified object to a byte value; returns the default value if the conversion fails.static char
Converts the specified object to a char value.static char
Converts the specified object to a char value; returns the default value if the conversion fails.static Date
Converts a given Number object to a Date.static Date
Converts a given object to a Date.static Date
Converts a given String object to a Date.static Date
Converts a given java.sql.Date object to a Date.static Date
Converts a given Time object to a Date.static Date
Converts a given Timestamp object to a Date.static Date
Converts a given Instant object to a Date.static Date
Converts a given LocalDate object to a Date.static Date
toDate
(LocalDateTime localDateTime) Converts a given LocalDateTime object to a Date.static Date
Converts a given LocalTime object to a Date.static Date
Converts a given Calendar object to a Date.static double
Converts the specified object to a double value.static double
Converts the specified object to a double value; returns the default value if the conversion fails.static float
Converts the specified object to a float value.static float
Converts the specified object to a float value; returns the default value if the conversion fails.static Instant
Converts a Number to an Instant.static Instant
Converts an Object to an Instant.static Instant
Converts a String to an Instant.static Instant
Converts a java.sql.Date to an Instant.static Instant
Converts a Time to an Instant.static Instant
Converts a Timestamp to an Instant.static Instant
Converts a LocalDate to an Instant.static Instant
toInstant
(LocalDateTime localDateTime) Converts a LocalDateTime to an Instant.static Instant
Converts a LocalTime to an Instant.static Instant
Converts a Calendar to an Instant.static Instant
Converts a Date to an Instant.static int
Converts the specified object to an int value.static int
Converts the specified object to an int value; returns the default value if the conversion fails.static LocalDate
toLocalDate
(Number number) Converts a Number representing an epoch millisecond timestamp to a LocalDate using the default zone ID defined in RifeConfig.static LocalDate
toLocalDate
(Object value) Converts an Object to a LocalDate.static LocalDate
toLocalDate
(String string) Converts a String representation of a date/time to a LocalDate using various parsing strategies.static LocalDate
toLocalDate
(Date date) Converts a java.sql.Date to a LocalDate.static LocalDate
toLocalDate
(Time time) Converts a Time to a LocalDate.static LocalDate
toLocalDate
(Timestamp ts) Converts a Timestamp to a LocalDate.static LocalDate
toLocalDate
(Instant instant) Converts an Instant to a LocalDate using the default zone ID defined in RifeConfig.static LocalDate
toLocalDate
(LocalDateTime localDateTime) Converts a LocalDateTime to a LocalDate.static LocalDate
toLocalDate
(LocalTime localTime) Converts a LocalTime to a LocalDate.static LocalDate
toLocalDate
(Calendar cal) Converts a Calendar to a LocalDate using the default zone ID defined in RifeConfig.static LocalDate
toLocalDate
(Date date) Converts a Date to a LocalDate using the default zone ID defined in RifeConfig.static LocalDateTime
toLocalDateTime
(Number number) Converts a Number to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Object value) Converts an Object to an LocalDateTime.static LocalDateTime
toLocalDateTime
(String string) Converts a String to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Date date) Converts a java.sql.Date to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Time time) Converts a java.sql.Time to a LocalDateTime object.static LocalDateTime
Converts a java.sql.Timestamp to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Instant instant) Converts an Instant to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(LocalDate localDate) Converts a LocalDate to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(LocalTime localTime) Converts a LocalTime to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Calendar cal) Converts a java.util.Calendar to a LocalDateTime object.static LocalDateTime
toLocalDateTime
(Date date) Converts a java.util.Date to a LocalDateTime object.static LocalTime
toLocalTime
(Number number) Converts a Number object to a LocalTime object.static LocalTime
toLocalTime
(Object value) Converts an Object to a LocalTime object.static LocalTime
toLocalTime
(String string) Converts a String object to a LocalTime object.static LocalTime
toLocalTime
(Date date) Converts a java.sql.Date object to a LocalTime object.static LocalTime
toLocalTime
(Time time) Converts a Time object to a LocalTime object.static LocalTime
toLocalTime
(Timestamp ts) Converts a Timestamp object to a LocalTime object.static LocalTime
toLocalTime
(Instant instant) Converts an Instant object to a LocalTime object.static LocalTime
toLocalTime
(LocalDate localDate) Converts a LocalDate object to a LocalTime object.static LocalTime
toLocalTime
(LocalDateTime localDateTime) Converts a LocalDateTime object to a LocalTime object.static LocalTime
toLocalTime
(Calendar cal) Converts a Calendar object to a LocalTime object.static LocalTime
toLocalTime
(Date date) Converts a Date object to a LocalTime object.static long
Converts the specified object to a long value.static long
Converts the specified object to a long value; returns the default value if the conversion fails.static short
Converts the specified object to a short value.static short
Converts the specified object to a short value; returns the default value if the conversion fails.static Date
Converts a Number object to a java.sql.Date object.static Date
Converts an object to a java.sql.Date object.static Date
Converts a String object to a java.sql.Date object.static Date
Converts an Instant object to a java.sql.Date object.static Date
Converts a LocalDate object to a java.sql.Date object.static Date
toSqlDate
(LocalDateTime localDateTime) Converts a LocalDateTime object to a java.sql.Date object.static Date
Converts a LocalTime object to a java.sql.Date object.static Date
Converts a java.util.Calendar object to a java.sql.Date object.static Date
Converts a java.util.Date object to a java.sql.Date object.static Time
Converts a Number object to a Time object.static Time
Converts an object to a TIme object.static Time
Converts a String object to a Time object.static Time
Converts a java.sql.Date object to a Time object.static Time
Converts a Timestamp object to a Time object.static Time
Converts an Instant object to a Time object.static Time
Converts a LocalDate object to a Time object.static Time
toSqlTime
(LocalDateTime localDateTime) Converts a LocalDateTime object to a Time object.static Time
Converts a LocalTime object to a Time object.static Time
Converts a Calendar object to a Time object.static Time
Converts a Date object to a Time object.static Timestamp
toSqlTimestamp
(Number number) Converts a Number object to a Timestamp object.static Timestamp
toSqlTimestamp
(Object value) Converts an object to a Timestamp object.static Timestamp
toSqlTimestamp
(String string) Converts a String object to a Timestamp object.static Timestamp
toSqlTimestamp
(Date date) Converts a java.sql.Date object to a Timestamp object.static Timestamp
toSqlTimestamp
(Time time) Converts a java.sql.Time object to a Timestamp object.static Timestamp
toSqlTimestamp
(Instant instant) static Timestamp
toSqlTimestamp
(LocalDate localDate) Converts a LocalDate object to a Timestamp object.static Timestamp
toSqlTimestamp
(LocalDateTime localDateTime) Converts a LocalDateTime object to a Timestamp object.static Timestamp
toSqlTimestamp
(LocalTime localTime) Converts a LocalTime object to a Timestamp object.static Timestamp
toSqlTimestamp
(Calendar cal) Converts a java.util.Calendar object to a Timestamp object.static Timestamp
toSqlTimestamp
(Date date) Converts a java.util.Date object to a Timestamp object.static String
Returns the string representation of the specified object.static Object
Converts the given value into the specified target class.
-
Method Details
-
toType
Converts the given value into the specified target class.- Parameters:
value
- the value to be converted.target
- the class representing the target type of the conversion.- Returns:
- the value converted to the target type
- Throws:
ConversionException
- if the value can't be converted to the target type.- Since:
- 1.0
-
fromString
Converts the given string into an object of specified type.- Parameters:
string
- the string to be converted.type
- the class representing the target type of the conversion.- Returns:
- the string converted to the target type.
- Throws:
ConversionException
- if the string can't be converted to the target type.- Since:
- 1.5.20
-
toString
Returns the string representation of the specified object.If
null
is provided as value, the result will also benull
and not the string literal"null"
.- Parameters:
value
- the object to convert to string.- Returns:
- the string representation of the specified object.
- Since:
- 1.0
-
toChar
Converts the specified object to a char value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to char.defaultValue
- the default value.- Returns:
- the char value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toChar
Converts the specified object to a char value.- Parameters:
value
- the object to convert to char.- Returns:
- the char value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a char value.- Since:
- 1.0
-
toBoolean
Converts the specified object to a boolean value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to boolean.defaultValue
- the default value.- Returns:
- the boolean value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toBoolean
Converts the specified object to a boolean value.- Parameters:
value
- the object to convert to boolean.- Returns:
- the boolean value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a boolean value.- Since:
- 1.0
-
toByte
Converts the specified object to a byte value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to byte.defaultValue
- the default value.- Returns:
- the byte value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toByte
Converts the specified object to a byte value.- Parameters:
value
- the object to convert to byte.- Returns:
- the byte value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a byte value.- Since:
- 1.0
-
toShort
Converts the specified object to a short value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to short.defaultValue
- the default value.- Returns:
- the short value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toShort
Converts the specified object to a short value.- Parameters:
value
- the object to convert to short.- Returns:
- the short value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a short value.- Since:
- 1.0
-
toInt
Converts the specified object to an int value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to int.defaultValue
- the default value.- Returns:
- the int value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toInt
Converts the specified object to an int value.- Parameters:
value
- the object to convert to int.- Returns:
- the int value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to an int value.- Since:
- 1.0
-
toLong
Converts the specified object to a long value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to long.defaultValue
- the default value.- Returns:
- the long value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toLong
Converts the specified object to a long value.- Parameters:
value
- the object to convert to long.- Returns:
- the long value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a long value.- Since:
- 1.0
-
toFloat
Converts the specified object to a float value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to float.defaultValue
- the default value.- Returns:
- the float value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toFloat
Converts the specified object to a float value.- Parameters:
value
- the object to convert to float.- Returns:
- the float value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a float value.- Since:
- 1.0
-
toDouble
Converts the specified object to a double value; returns the default value if the conversion fails.- Parameters:
value
- the object to convert to double.defaultValue
- the default value.- Returns:
- the double value represented by the specified object or the default value if the conversion fails.
- Since:
- 1.0
-
toDouble
Converts the specified object to a double value.- Parameters:
value
- the object to convert to double.- Returns:
- the double value represented by the specified object.
- Throws:
ConversionException
- if the specified object cannot be converted to a double value.- Since:
- 1.0
-
toDate
Converts a given Calendar object to a Date.- Parameters:
cal
- the Calendar object to be converted to a Date- Returns:
- the Date representing the Calendar object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given java.sql.Date object to a Date.- Parameters:
date
- the java.sql.Date object to be converted to a Date- Returns:
- the Date representing the java.sql.Date object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given Time object to a Date.- Parameters:
time
- the Time object to be converted to a Date- Returns:
- the Date representing the Time object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given Timestamp object to a Date.- Parameters:
ts
- the Timestamp object to be converted to a Date- Returns:
- the Date representing the Timestamp object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given Instant object to a Date.- Parameters:
instant
- the Instant object to be converted to a Date- Returns:
- the Date representing the Instant object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given LocalDateTime object to a Date.- Parameters:
localDateTime
- the LocalDateTime object to be converted to a Date- Returns:
- the Date representing the LocalDateTime object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given LocalDate object to a Date.- Parameters:
localDate
- the LocalDate object to be converted to a Date- Returns:
- the Date representing the LocalDate object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given LocalTime object to a Date.- Parameters:
localTime
- the LocalTime object to be converted to a Date- Returns:
- the Date representing the LocalTime object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given Number object to a Date.- Parameters:
number
- the Number object to be converted to a Date- Returns:
- the Date representing the Number object passed as parameter, or null if it is null
- Since:
- 1.0
-
toDate
Converts a given String object to a Date.- Parameters:
string
- the String object to be converted to a Date- Returns:
- the Date representing the String object passed as parameter, or null if it is null
- Throws:
ConversionException
- if the String object passed cannot be converted to a Date- Since:
- 1.0
-
toDate
Converts a given object to a Date. Depending on the type of the object passed, it uses the appropriate method to convert it to a Date.- Parameters:
value
- the Object to be converted to a Date- Returns:
- the Date representing the Object passed as parameter, or null if it is null
- Throws:
ConversionException
- if the Object passed cannot be converted to a Date- Since:
- 1.0
-
toSqlDate
Converts a java.util.Date object to a java.sql.Date object.- Parameters:
date
- the java.util.Date object to be converted- Returns:
- a java.sql.Date object representing the same date as the input
- Since:
- 1.0
-
toSqlDate
Converts a java.util.Calendar object to a java.sql.Date object.- Parameters:
cal
- the java.util.Calendar object to be converted- Returns:
- a java.sql.Date object representing the same date as the input
- Since:
- 1.0
-
toSqlDate
Converts an Instant object to a java.sql.Date object.- Parameters:
instant
- the Instant object to be converted- Returns:
- a java.sql.Date object representing the same date as the input
- Since:
- 1.0
-
toSqlDate
Converts a LocalDateTime object to a java.sql.Date object.- Parameters:
localDateTime
- the LocalDateTime object to be converted- Returns:
- a java.sql.Date object representing the same date as the input
- Since:
- 1.0
-
toSqlDate
Converts a LocalDate object to a java.sql.Date object.- Parameters:
localDate
- the LocalDate object to be converted- Returns:
- a java.sql.Date object representing the same date as the input with time set to midnight
- Since:
- 1.0
-
toSqlDate
Converts a LocalTime object to a java.sql.Date object.- Parameters:
localTime
- the LocalTime object to be converted- Returns:
- a java.sql.Date object representing the same time as the input with date set to epoch (1970-01-01)
- Since:
- 1.0
-
toSqlDate
Converts a Number object to a java.sql.Date object.- Parameters:
number
- the Number object to be converted- Returns:
- a java.sql.Date object representing the same date as the input
- Since:
- 1.0
-
toSqlDate
Converts a String object to a java.sql.Date object.- Parameters:
string
- the String object to be converted- Returns:
- a java.sql.Date object representing the same date as the input, parsed using a default format or specified format (if possible)
- Throws:
ConversionException
- if the input cannot be parsed to a java.sql.Date object using any of the available formats- Since:
- 1.0
-
toSqlDate
Converts an object to a java.sql.Date object.- Parameters:
value
- the object to be converted- Returns:
- a java.sql.Date object representing the same date as the input, if the input is one of the supported types
- Throws:
ConversionException
- if the input is not one of the supported types- Since:
- 1.0
-
toSqlTimestamp
Converts a java.sql.Date object to a Timestamp object.- Parameters:
date
- the java.sql.Date object to be converted- Returns:
- a Timestamp object representing the same date and time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a java.sql.Time object to a Timestamp object.- Parameters:
time
- the java.sql.Time object to be converted- Returns:
- a Timestamp object representing the same time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a java.util.Date object to a Timestamp object.- Parameters:
date
- the java.util.Date object to be converted- Returns:
- a Timestamp object representing the same date and time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a java.util.Calendar object to a Timestamp object.- Parameters:
cal
- the java.util.Calendar object to be converted- Returns:
- a Timestamp object representing the same date and time as the input
- Since:
- 1.0
-
toSqlTimestamp
-
toSqlTimestamp
Converts a LocalDateTime object to a Timestamp object.- Parameters:
localDateTime
- the LocalDateTime object to be converted- Returns:
- a Timestamp object representing the same date and time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a LocalDate object to a Timestamp object.- Parameters:
localDate
- the LocalDate object to be converted- Returns:
- a Timestamp object representing the same date and time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a LocalTime object to a Timestamp object.- Parameters:
localTime
- the LocalTime object to be converted- Returns:
- a Timestamp object representing the same time as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a Number object to a Timestamp object.- Parameters:
number
- the Number object to be converted- Returns:
- a Timestamp object representing the same time in milliseconds since Epoch as the input
- Since:
- 1.0
-
toSqlTimestamp
Converts a String object to a Timestamp object.- Parameters:
string
- the String object to be converted to a Timestamp- Returns:
- a Timestamp object representing the same time as the input
- Throws:
ConversionException
- if the given string cannot be parsed as a timestamp- Since:
- 1.0
-
toSqlTimestamp
Converts an object to a Timestamp object.- Parameters:
value
- the object to be converted to a Timestamp- Returns:
- object representing the same timestamp as the input, if the input is one of the supported types
- Throws:
ConversionException
- if the input is not one of the supported types- Since:
- 1.0
-
toSqlTime
Converts a Timestamp object to a Time object.- Parameters:
ts
- the Timestamp object to be converted- Returns:
- a Time object representing the same time as the input Timestamp object
- Since:
- 1.0
-
toSqlTime
Converts a java.sql.Date object to a Time object.- Parameters:
date
- the java.sql.Date object to be converted- Returns:
- a Time object representing the same time as the input java.sql.Date object
- Since:
- 1.0
-
toSqlTime
Converts a Date object to a Time object.- Parameters:
date
- the Date object to be converted- Returns:
- a Time object representing the same time as the input Date object
- Since:
- 1.0
-
toSqlTime
Converts a Calendar object to a Time object.- Parameters:
cal
- the Calendar object to be converted- Returns:
- a Time object representing the same time as the input Calendar object
- Since:
- 1.0
-
toSqlTime
Converts an Instant object to a Time object.- Parameters:
instant
- the Instant object to be converted- Returns:
- a Time object representing the same time as the input Instant object
- Since:
- 1.0
-
toSqlTime
Converts a LocalDateTime object to a Time object.- Parameters:
localDateTime
- the LocalDateTime object to be converted- Returns:
- a Time object representing the same time as the input LocalDateTime object
- Since:
- 1.0
-
toSqlTime
Converts a LocalDate object to a Time object.- Parameters:
localDate
- the LocalDate object to be converted- Returns:
- a Time object representing midnight for the input LocalDate object
- Since:
- 1.0
-
toSqlTime
Converts a LocalTime object to a Time object.- Parameters:
localTime
- the LocalTime object to be converted- Returns:
- a Time object representing the same time as the input LocalTime object on January 1, 1970
- Since:
- 1.0
-
toSqlTime
Converts a Number object to a Time object.- Parameters:
number
- the Number object to be converted- Returns:
- a Time object representing the same time as the input Number object, treated as a number of milliseconds since January 1, 1970
- Since:
- 1.0
-
toSqlTime
Converts a String object to a Time object.- Parameters:
string
- the String object to be converted- Returns:
- a Time object representing the same time as the input String object
- Throws:
ConversionException
- if the input String cannot be parsed as a Time object- Since:
- 1.0
-
toSqlTime
Converts an object to a TIme object.- Parameters:
value
- the object to be converted to a Time- Returns:
- object representing the same time as the input, if the input is one of the supported types
- Throws:
ConversionException
- if the input is not one of the supported types- Since:
- 1.0
-
toInstant
Converts a java.sql.Date to an Instant.- Parameters:
date
- the date to be converted.- Returns:
- the instant representing the provided date or null if the date is null.
- Since:
- 1.0
-
toInstant
Converts a Time to an Instant.- Parameters:
time
- the time to be converted.- Returns:
- the instant representing the provided time or null if the time is null.
- Since:
- 1.0
-
toInstant
Converts a Timestamp to an Instant.- Parameters:
ts
- the timestamp to be converted.- Returns:
- the instant representing the provided timestamp or null if the timestamp is null.
- Since:
- 1.0
-
toInstant
Converts a Date to an Instant.- Parameters:
date
- the date to be converted.- Returns:
- the instant representing the provided date or null if the date is null.
- Since:
- 1.0
-
toInstant
Converts a Calendar to an Instant.- Parameters:
cal
- the calendar to be converted.- Returns:
- the instant representing the provided calendar or null if the calendar is null.
- Since:
- 1.0
-
toInstant
Converts a LocalDateTime to an Instant.- Parameters:
localDateTime
- the LocalDateTime to be converted.- Returns:
- the instant representing the provided LocalDateTime or null if the LocalDateTime is null.
- Since:
- 1.0
-
toInstant
Converts a LocalDate to an Instant.- Parameters:
localDate
- the LocalDate to be converted.- Returns:
- the instant representing the provided LocalDate or null if the LocalDate is null.
- Since:
- 1.0
-
toInstant
Converts a LocalTime to an Instant.- Parameters:
localTime
- the LocalTime to be converted.- Returns:
- the instant representing the provided LocalTime or null if the LocalTime is null.
- Since:
- 1.0
-
toInstant
Converts a Number to an Instant.- Parameters:
number
- the Number to be converted.- Returns:
- the instant representing the provided Number or null if the Number is null.
- Since:
- 1.0
-
toInstant
Converts a String to an Instant.- Parameters:
string
- the String to be converted.- Returns:
- the instant representing the provided String or null if the String is null.
- Throws:
ConversionException
- if the String cannot be converted to an Instant.- Since:
- 1.0
-
toInstant
Converts an Object to an Instant.- Parameters:
value
- the Object to be converted.- Returns:
- the instant representing the provided Object or null if the Object is null.
- Throws:
ConversionException
- if the Object cannot be converted to an Instant.- Since:
- 1.0
-
toLocalDateTime
Converts a java.sql.Timestamp to a LocalDateTime object.- Parameters:
ts
- the java.sql.Timestamp to convert- Returns:
- the LocalDateTime object equivalent to the given timestamp, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a java.sql.Date to a LocalDateTime object.- Parameters:
date
- the java.sql.Date to convert- Returns:
- the LocalDateTime object equivalent to the given date, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a java.sql.Time to a LocalDateTime object.- Parameters:
time
- the java.sql.Time to convert- Returns:
- the LocalDateTime object equivalent to the given time, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a java.util.Date to a LocalDateTime object.- Parameters:
date
- the java.util.Date to convert- Returns:
- the LocalDateTime object equivalent to the given date, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a java.util.Calendar to a LocalDateTime object.- Parameters:
cal
- the java.util.Calendar to convert- Returns:
- the LocalDateTime object equivalent to the given calendar, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts an Instant to a LocalDateTime object.- Parameters:
instant
- the Instant to convert- Returns:
- the LocalDateTime object equivalent to the given instant, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a LocalDate to a LocalDateTime object.- Parameters:
localDate
- the LocalDate to convert- Returns:
- the LocalDateTime object representing the start of the given date, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a LocalTime to a LocalDateTime object.- Parameters:
localTime
- the LocalTime to convert- Returns:
- the LocalDateTime object representing the given time on Jan 1, 1970, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a Number to a LocalDateTime object.- Parameters:
number
- the Number object to convert- Returns:
- the LocalDateTime object equivalent to the millisecond epoch value of the given number, or null if the input is null.
- Since:
- 1.0
-
toLocalDateTime
Converts a String to a LocalDateTime object.- Parameters:
string
- the String to convert- Returns:
- the LocalDateTime object parsed from the given string, or null if the input is null.
- Throws:
ConversionException
- if the string cannot be parsed as a LocalDateTime object- Since:
- 1.0
-
toLocalDateTime
Converts an Object to an LocalDateTime.- Parameters:
value
- the Object to convert- Returns:
- the LocalDateTime object corresponding to the given object, or null if the input is null.
- Throws:
ConversionException
- if the object cannot be converted to a LocalDateTime object- Since:
- 1.0
-
toLocalDate
Converts a Timestamp to a LocalDate.- Parameters:
ts
- The Timestamp to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a java.sql.Date to a LocalDate.- Parameters:
date
- The sql Date to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a Time to a LocalDate. Always returns LocalDate.EPOCH.- Parameters:
time
- The Time to convert- Returns:
- LocalDate.EPOCH, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a Date to a LocalDate using the default zone ID defined in RifeConfig.- Parameters:
date
- The Date to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a Calendar to a LocalDate using the default zone ID defined in RifeConfig.- Parameters:
cal
- The Calendar to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts an Instant to a LocalDate using the default zone ID defined in RifeConfig.- Parameters:
instant
- The Instant to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a LocalDateTime to a LocalDate.- Parameters:
localDateTime
- The LocalDateTime to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a LocalTime to a LocalDate. Always returns LocalDate.EPOCH.- Parameters:
localTime
- The LocalTime to convert- Returns:
- LocalDate.EPOCH, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a Number representing an epoch millisecond timestamp to a LocalDate using the default zone ID defined in RifeConfig.- Parameters:
number
- The Number to convert- Returns:
- The corresponding LocalDate, or null if the input is null
- Since:
- 1.0
-
toLocalDate
Converts a String representation of a date/time to a LocalDate using various parsing strategies.- Parameters:
string
- The String to convert- Returns:
- The corresponding LocalDate
- Throws:
ConversionException
- If the input string cannot be parsed as a LocalDate- Since:
- 1.0
-
toLocalDate
Converts an Object to a LocalDate.- Parameters:
value
- The Object to convert- Returns:
- The corresponding LocalDate
- Throws:
ConversionException
- If the input Object cannot be converted to a LocalDate- Since:
- 1.0
-
toLocalTime
Converts a java.sql.Date object to a LocalTime object.- Parameters:
date
- the java.sql.Date object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a Timestamp object to a LocalTime object.- Parameters:
ts
- the Timestamp object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a Time object to a LocalTime object.- Parameters:
time
- the Time object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a Date object to a LocalTime object.- Parameters:
date
- the Date object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a Calendar object to a LocalTime object.- Parameters:
cal
- the Calendar object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts an Instant object to a LocalTime object.- Parameters:
instant
- the Instant object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a LocalDateTime object to a LocalTime object.- Parameters:
localDateTime
- the LocalDateTime object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a LocalDate object to a LocalTime object.- Parameters:
localDate
- the LocalDate object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a Number object to a LocalTime object.- Parameters:
number
- the Number object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Since:
- 1.0
-
toLocalTime
Converts a String object to a LocalTime object.- Parameters:
string
- the String object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Throws:
ConversionException
- if the conversion process fails- Since:
- 1.0
-
toLocalTime
Converts an Object to a LocalTime object.- Parameters:
value
- the Object to convert- Returns:
- the resulting LocalTime object or null if the input is null
- Throws:
ConversionException
- if the conversion process fails- Since:
- 1.0
-
getDefaultValue
Returns the default value of a given class.- Parameters:
clazz
- the class whose default value is to be returned- Returns:
- the default value of the given class
- Since:
- 1.0
-