|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javalite.common.Convert
public class Convert
Convenience class for type conversions.
| Constructor Summary | |
|---|---|
Convert()
|
|
| Method Summary | |
|---|---|
static BigDecimal |
toBigDecimal(Object value)
Converts value to BigDecimal if c 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 'y', 't', 'true' or 'yes'. |
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 c it can. |
static Integer |
toInteger(Object value)
Converts value to Integer if c it can. |
static Long |
toLong(Object value)
Converts value to Long if c it can. |
static Date |
toSqlDate(Object value)
Expects a java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date 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 Timestamp |
toTimestamp(Object value)
If the value is instance of java.sql.Timestamp, returns it, else tries to convert the value to Timestamp using Timestamp.valueOf(String). |
static Date |
truncateToSqlDate(Object value)
Expects a java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date or
string with format: yyyy-mm-dd. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Convert()
| Method Detail |
|---|
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 convert
public static Date toSqlDate(Object value)
java.sql.Date, java.sql.Timestamp, java.sql.Time, java.util.Date 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 or
string with format: yyyy-mm-dd. This method will also 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.
- Parameters:
value- argument that is possible to convert tojava.sql.Date:java.sql.Date,java.sql.Timestamp,java.sql.Time,java.util.Dateor any object with toString() ==yyyy-mm-dd.- Returns:
java.sql.Dateinstance representing input value.
public static Double toDouble(Object value)
Double.
value - value to convert.
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)
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||