public final class Convert extends Object
| Modifier and Type | Method and Description | 
|---|---|
static BigDecimal | 
toBigDecimal(Object value)
Converts value to BigDecimal if it can. 
 | 
static Boolean | 
toBoolean(Object value)
Returns true if the value is any numeric type and has a value of 1, or
 if string type has a value of '1', 't', 'y', 'true' or 'yes'. 
 | 
static byte[] | 
toBytes(Blob blob)
Converts  
java.sql.Blob to bytes array. | 
static byte[] | 
toBytes(Object value)
Converts value to bytes array if it can. 
 | 
static Double | 
toDouble(Object value)
Converts any value to  
Double. | 
static Float | 
toFloat(Object value)
Converts value to Float if it can. 
 | 
static Integer | 
toInteger(Object value)
Converts value to Integer if it can. 
 | 
static String | 
toIsoString(Date date)
Converts a  
java.util.Date to a String in ISO 8601 format: "yyyy-MM-dd'T'HH:mm:ss'Z'"
 in UTC timezone for timestamps, and "yyyy-MM-dd" for instances of java.sql.Date. | 
static Long | 
toLong(Object value)
Converts value to  
Long if it can. | 
static Short | 
toShort(Object value)
Converts value to Short if it can. 
 | 
static Date | 
toSqlDate(Object value)
Expects a  
java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date,
 Long or any object whose toString method has this format: yyyy-mm-dd. | 
static String | 
toString(Object value)
Returns string representation of an object, including  
Clob. | 
static Time | 
toTime(Object value)
If the value is instance of java.sql.Time, returns it, else tries to convert java.util.Date or Long to
 Time, else tries to convert using  
Time.valueOf(String). | 
static Timestamp | 
toTimestamp(Object value)
If the value is instance of java.sql.Timestamp, returns it, else tries to convert java.util.Date or Long to
 Timestamp, else tries to convert using  
Timestamp.valueOf(String). | 
static Date | 
truncateToSqlDate(long time)
This method will truncate hours, minutes, seconds and milliseconds to zeros, to conform with JDBC spec:
 http://download.oracle.com/javase/6/docs/api/java/sql/Date.html. 
 | 
static Date | 
truncateToSqlDate(Object value)
Expects a  
java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date,
 Long or string with format "yyyy-MM-dd". | 
public static String toString(Object value)
Clob.
 For large CLOBs, be careful because this will load an entire CLOB in memory as java.lang.String.value - value to convert.Clob.public static Boolean toBoolean(Object value)
value - value to convertpublic static Date toSqlDate(Object value)
java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date,
 Long or any object whose toString method has this format: yyyy-mm-dd.value - argument that is possible to convert to java.sql.Date.java.sql.Date instance representing input value.public static Date truncateToSqlDate(Object value)
java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date,
 Long or string with format "yyyy-MM-dd". This method will truncate hours, minutes, seconds and
 milliseconds to zeros, to conform with JDBC spec:
 http://download.oracle.com/javase/6/docs/api/java/sql/Date.html.
 This method is tread-safe.
value - argument that is possible to convert to java.sql.Date: java.sql.Date,
 java.sql.Timestamp, java.sql.Time, java.util.Date, Long or any object with toString() == yyyy-mm-dd.java.sql.Date instance representing input value.public static Date truncateToSqlDate(long time)
time - time in UTC milliseconds from the epochpublic static String toIsoString(Date date)
java.util.Date to a String in ISO 8601 format: "yyyy-MM-dd'T'HH:mm:ss'Z'"
 in UTC timezone for timestamps, and "yyyy-MM-dd" for instances of java.sql.Date.
 This method is tread-safe.
date - date to convertpublic static Double toDouble(Object value)
Double.value - value to convert.public static Time toTime(Object value)
Time.valueOf(String).
 This method might trow IllegalArgumentException if fails at conversion.value - value to convertTime.valueOf(String)public static Timestamp toTimestamp(Object value)
Timestamp.valueOf(String).
 This method might trow IllegalArgumentException if fails at conversion.value - value to convert.Timestamp.valueOf(String)public static Float toFloat(Object value)
value - value to be converted to Float.public static Long toLong(Object value)
Long if it can. If value is a Long, it is returned, if it is a Number, it is
 promoted to Long and then returned, if it is a Date, returns its getTime() value, in all other cases, it converts the value to String,
 then tries to parse Long from it.value - value to be converted to Long.public static Integer toInteger(Object value)
value - value to be converted to Integer.public static BigDecimal toBigDecimal(Object value)
value - value to be converted to Integer.public static byte[] toBytes(Object value)
java.sql.Blob, then data is read from it as bytes.
 In all other cases the object is converted to String, then bytes are read from it.value - value to be converted.public static byte[] toBytes(Blob blob)
java.sql.Blob to bytes array.blob - Blob to be convertedpublic static Short toShort(Object value)
value - value to be converted to Integer.Copyright © 2020 JavaLite. All rights reserved.