Java Date to Timestamp dateToTimestamp(Date date)

Here you can find the source of dateToTimestamp(Date date)

Description

A Utility method to convert a Date instance to Timestamp instance.

License

Open Source License

Parameter

Parameter Description
date the date to convert.

Return

the timestamp

Declaration

static Timestamp dateToTimestamp(Date date) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;
import java.util.Date;

public class Main {
    /**//ww  w  .j  ava 2  s .c o  m
     * A Utility method to convert a Date instance to Timestamp instance.
     *
     * @param date
     *            the date to convert.
     * @return the timestamp
     */
    static Timestamp dateToTimestamp(Date date) {
        if (date == null) {
            date = new Date();
        }
        return new Timestamp(date.getTime());
    }
}

Related

  1. compareDate(String timeStamp1, String timeStamp2)
  2. dateToTimestamp(Date date)
  3. dateToTimestamp(Date date)
  4. dateToTimestamp(Date date)
  5. dateToTimestamp(Date date)
  6. DateToTimestamp(Date time)
  7. dateToTimestamp(java.util.Date d)
  8. dateToTimeStamp(java.util.Date date)
  9. dateToTimestamp(java.util.Date date)