Here you can find the source of stringToTimestamp(String sTimestamp)
public static Timestamp stringToTimestamp(String sTimestamp) throws Exception
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Timestamp stringToTimestamp(String sTimestamp) throws Exception { Date d;//from w w w . j a v a 2s . c om SimpleDateFormat stringToDate; try { stringToDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.S"); d = stringToDate.parse(sTimestamp); } catch (ParseException e) { stringToDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); d = stringToDate.parse(sTimestamp); } return new Timestamp(d.getTime()); } }