Here you can find the source of toTimestamp(Object dateobj)
public static java.sql.Timestamp toTimestamp(Object dateobj) throws Exception
//package com.java2s; //License from project: LGPL import java.util.Date; import java.text.*; public class Main { public static java.sql.Timestamp toTimestamp(Object dateobj) throws Exception { return toTimestamp(dateobj.toString()); }/*from ww w .j ava2 s . c o m*/ /** * Converts date from String to sql timeStamp type using the default Format (EEE MMM dd H:mm:ss z yyyy). * @param DateString * @return java.sql.Timestamp * @throws Exception */ public static java.sql.Timestamp toTimestamp(String DateString) throws Exception { long longDate = (long) new Date().getTime(); try { java.sql.Date sdt; SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd H:mm:ss z yyyy"); java.util.Date udt = (java.util.Date) sdf.parse(DateString); longDate = (long) udt.UTC(udt.getYear(), udt.getMonth(), udt.getDate(), udt.getHours(), udt.getMinutes(), udt.getSeconds()); } catch (ParseException e) { throw new Exception(e.getMessage()); } return new java.sql.Timestamp(longDate); } }