public static java . sql . Date convertDate ( String date , Locale locale ) { SimpleDateFormat df ; java . util . Date dbDate = null ; java . sql . Date sqldate = null ; try { if ( date == null || date . equals ( "" ) ) { return null ; } df = ( SimpleDateFormat ) DateFormat . getDateInstance ( dateStyle , locale ) ; SimpleDateFormat sdf = new SimpleDateFormat ( df . toPattern ( ) ) ; java . text . ParsePosition pos = new java . text . ParsePosition ( 0 ) ; sdf . setLenient ( false ) ; dbDate = sdf . parse ( date , pos ) ; return new java . sql . Date ( dbDate . getTime ( ) ) ; } catch ( Exception e ) { return null ; } }
Converts the users input date value to java . sql . Date