Here you can find the source of convertStringToTimeStamp(String date)
public static Timestamp convertStringToTimeStamp(String date)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Timestamp convertStringToTimeStamp(String date) { //19// www.ja va 2 s .c om if (null == date || date.isEmpty()) { return null; } Timestamp ts = null; if (date.indexOf("/") != -1) { date = date.replace("/", "-"); } try { SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date11 = df1.parse(date); String time = df1.format(date11); ts = Timestamp.valueOf(time); } catch (Exception e) { e.printStackTrace(); } return ts; } }