Java Utililty Methods Date to Timestamp

List of utility methods to do Date to Timestamp

Description

The list of methods to do Date to Timestamp are organized into topic(s).

Method

intcompareDate(String timeStamp1, String timeStamp2)
compare Date
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
try {
    Date d1 = sdf.parse(timeStamp1);
    Date d2 = sdf.parse(timeStamp2);
    if (d1.compareTo(d2) == 0) {
        return -1;
    return d1.compareTo(d2);
...
TimestampdateToTimestamp(Date date)
date To Timestamp
return new Timestamp(date.getTime());
TimestampdateToTimestamp(Date date)
Converts a java.util.Date to a java.sql.Timestamp.
return date == null ? null : new Timestamp(date.getTime());
TimestampdateToTimestamp(Date date)
useful for webservice because we can not use java.sql.date in wsdl
if (date == null)
    return null;
java.sql.Timestamp stamp = new Timestamp(date.getTime());
return stamp;
TimestampdateToTimestamp(Date date)
date To Timestamp
String temp = CHN_DATE_TIME_EXTENDED_FORMAT.format(date);
return Timestamp.valueOf(temp);
TimestampdateToTimestamp(Date date)
A Utility method to convert a Date instance to Timestamp instance.
if (date == null) {
    date = new Date();
return new Timestamp(date.getTime());
IntegerDateToTimestamp(Date time)
Date To Timestamp
Timestamp ts = new Timestamp(time.getTime());
return (int) ((ts.getTime()) / 1000);
java.sql.TimestampdateToTimestamp(java.util.Date d)
Converts a date to a SQL timestamp
if (d == null) {
    return null;
java.sql.Timestamp ts;
ts = new java.sql.Timestamp(d.getTime());
return ts;
TimestampdateToTimeStamp(java.util.Date date)
date To Time Stamp
Calendar cal = dateToCalendar(date);
return calToTimeStamp(cal);
TimestampdateToTimestamp(java.util.Date date)

Description: Change the java.util.date format to java.sql.Timestamp format

return new Timestamp(date.getTime());