Here you can find the source of getstrTimestamp(String datetime)
public static Timestamp getstrTimestamp(String datetime)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static Timestamp getstrTimestamp(String datetime) { java.util.Date bb = new java.util.Date(datetime); if (bb != null) { return new Timestamp(bb.getTime()); } else {// w w w . j a v a 2s . c o m return null; } } public static Timestamp getstrTimestamp(String datetime, String datepattern) { java.util.Date bb = null; try { DateFormat parser = new SimpleDateFormat(datepattern); bb = parser.parse(datetime); return new Timestamp(bb.getTime()); } catch (ParseException ex) { } return null; } }