Here you can find the source of getCurTime2Timestamp()
public static Timestamp getCurTime2Timestamp() throws ParseException
//package com.java2s; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static Timestamp getCurTime2Timestamp() throws ParseException { Timestamp t = new Timestamp(System.currentTimeMillis()); String d2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(t); Timestamp.valueOf(d2);// w w w. ja v a 2 s . co m return t; } }