Here you can find the source of strToSqlDate(String format, String value)
public static java.sql.Date strToSqlDate(String format, String value) throws ParseException
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static java.sql.Date strToSqlDate(String format, String value) throws ParseException { Date utilDate = strToJavaDate(format, value); return convertJavaDateToSqlDate(utilDate); }/*from www .ja va 2 s. c o m*/ public static Date strToJavaDate(String format, String value) throws ParseException { Date date = null; try { SimpleDateFormat formatter = new SimpleDateFormat(format); formatter.setLenient(false); //make it strict date = formatter.parse(value); } catch (ParseException e) { throw new ParseException("Failed to parse the " + value + " to Date by format[" + format + "].", 1); } return date; } public static java.sql.Date convertJavaDateToSqlDate(Date javaDate) throws ParseException { java.sql.Date sqlDate = null; if (javaDate != null) { sqlDate = new java.sql.Date(javaDate.getTime()); } return sqlDate; } }