Here you can find the source of stringToTimestamp(String date, String formatStr)
public static Timestamp stringToTimestamp(String date, String formatStr)
//package com.java2s; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static Timestamp stringToTimestamp(String date, String formatStr) { SimpleDateFormat format = new SimpleDateFormat(formatStr); format.setLenient(false);// ww w . j a v a2s . c o m try { Timestamp ts = new Timestamp(format.parse(date).getTime()); return ts; } catch (ParseException e) { e.printStackTrace(); return null; } } }