public static Date toDate ( String s ) { // Build a date formatter using the format specified by dateFormat DateFormat dateFormatter = new SimpleDateFormat ( dateFormat ) ; try { return dateFormatter . parse ( s ) ; } catch ( ParseException e ) { // Exception noted so can be ignored. e = null ; return null ; } }
Converts a string to a date . The string must be a date in the correct format or this method will return null .