Here you can find the source of getTimestamp(Date date)
public static Timestamp getTimestamp(Date date)
//package com.java2s; //License from project: LGPL import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Timestamp getTimestamp(long millis) { return new Timestamp(millis); }/* www .j a va 2s .c om*/ public static Timestamp getTimestamp(String time) { return new Timestamp(Long.parseLong(time)); } public static Timestamp getTimestamp() { return new Timestamp(new Date().getTime()); } public static Timestamp getTimestamp(Date date) { return new Timestamp(date.getTime()); } public static Timestamp gettimestamp() { Date dt = new Date(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String nowTime = df.format(dt); java.sql.Timestamp buydate = java.sql.Timestamp.valueOf(nowTime); return buydate; } }