public class DateHelper extends Object
Constructor and Description |
---|
DateHelper() |
Modifier and Type | Method and Description |
---|---|
static Calendar |
toCalendar(Object dt)
Try to convert the given object to a java.util.Calendar
|
static Date |
toDate(Object dt)
Try to convert the given object to a java.util.Date
|
static Date |
toSQLDate(Object dt)
Try to convert the given object to a java.sql.Date
|
static Timestamp |
toTimestamp(Object dt)
Try to convert the given object to a java.sql.Timestamp
|
public static Date toDate(Object dt) throws ClassCastException
dt
- Object of class java.util.Date, java.sql.Date, java.util.Calendar, java.sql.Timestamp or String The recognized string formats are: "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "dd-MM-yyyy" and "yyyyMMdd"ClassCastException
- if the conversion cannot be performedpublic static Calendar toCalendar(Object dt) throws ClassCastException
dt
- Object of class java.util.Date, java.sql.Date, java.util.Calendar, java.sql.Timestamp or String
The recognized string formats are: "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "dd-MM-yyyy" and "yyyyMMdd"ClassCastException
- if the conversion cannot be performedpublic static Timestamp toTimestamp(Object dt) throws ClassCastException
dt
- Object of class java.util.Date, java.sql.Date, java.util.Calendar, java.sql.Timestamp or String
The recognized string formats are: "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "dd-MM-yyyy" and "yyyyMMdd"ClassCastException
- if the conversion cannot be performedpublic static Date toSQLDate(Object dt) throws ClassCastException
dt
- Object of class java.util.Date, java.sql.Date, java.util.Calendar, java.sql.Timestamp or String
The recognized string formats are: "yyyy-MM-dd", "dd-MM-yyyy" and "yyyyMMdd"ClassCastException
- if the conversion cannot be performedCopyright © 2001–2019 KnowGate. All rights reserved.