Here you can find the source of str2Timestamp(String str)
public static Timestamp str2Timestamp(String str)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat date_sdf = new SimpleDateFormat("yyyy-MM-dd"); public static Timestamp str2Timestamp(String str) { Date date = str2Date(str, date_sdf); return new Timestamp(date.getTime()); }/*w w w . ja v a 2s. c o m*/ public static Date str2Date(String str, SimpleDateFormat sdf) { if (null == str || "".equals(str)) { return null; } Date date = null; try { date = sdf.parse(str); return date; } catch (ParseException e) { e.printStackTrace(); } return null; } }