Here you can find the source of StrToTimestamp(String timestampStr,String pattern)
public static Timestamp StrToTimestamp(String timestampStr,String pattern) throws ParseException
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.text.ParseException; public class Main { public static Timestamp StrToTimestamp(String timestampStr, String pattern) throws ParseException { java.util.Date date = null; SimpleDateFormat format = new SimpleDateFormat(pattern); try {// ww w .ja v a 2 s .c o m date = format.parse(timestampStr); } catch (ParseException ex) { throw ex; } return date == null ? null : new Timestamp(date.getTime()); } }