Here you can find the source of parseTimestamp(String dateStr, String format)
public static java.sql.Timestamp parseTimestamp(String dateStr, String format)
//package com.java2s; //License from project: Apache License import java.util.*; import java.text.*; public class Main { public static java.sql.Timestamp parseTimestamp(String dateStr, String format) { java.util.Date date = parseDate(dateStr, format); if (date != null) { long t = date.getTime(); return new java.sql.Timestamp(t); } else/*from w ww . j a v a2 s.co m*/ return null; } public static Date parseDate(java.sql.Date date) { return date; } public static java.util.Date parseDate(String dateStr, String formatStr) { SimpleDateFormat format = new SimpleDateFormat(formatStr); try { return format.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); return null; } } }