Here you can find the source of getTimestamp2()
public static Timestamp getTimestamp2()
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Timestamp getTimestamp2() { 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; }//from w ww. j av a2 s.co m }