Here you can find the source of getSqlDate(String dateString, String format)
public static java.sql.Date getSqlDate(String dateString, String format) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; public class Main { public static java.sql.Date getSqlDate(String dateString) throws ParseException, NullPointerException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); ParsePosition pos = new ParsePosition(0); java.util.Date d = sdf.parse(dateString, pos); return new java.sql.Date(d.getTime()); }//from w w w . ja v a 2 s . com public static java.sql.Date getSqlDate(String dateString, String format) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); java.util.Date d = sdf.parse(dateString, pos); return new java.sql.Date(d.getTime()); } }