Here you can find the source of stringToSQLDate(String pstrValue, String pstrDateFormat)
public static java.sql.Date stringToSQLDate(String pstrValue, String pstrDateFormat) 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 { /**/*from w ww.j a v a 2 s . c o m*/ * String convert to SQLDate. * * @return a java.sql.Date representatio of the given date string and format * string. */ public static java.sql.Date stringToSQLDate(String pstrValue, String pstrDateFormat) throws ParseException { if ((pstrValue == null) || (pstrValue.equals(""))) { return null; } Date dttTempDate = stringToDate(pstrValue, pstrDateFormat); return new java.sql.Date(dttTempDate.getTime()); } /** * Convert string to Date * * @return a java.util.Date object converted. */ public static Date stringToDate(String pstrValue, String pstrDateFormat) { if ((pstrValue == null) || (pstrValue.equals(""))) { return null; } Date dttDate = null; try { SimpleDateFormat oFormatter = new SimpleDateFormat(pstrDateFormat); dttDate = oFormatter.parse(pstrValue); oFormatter = null; } catch (Exception e) { return null; } return dttDate; } }