public static Date parseToDate ( final String datum , final String [ ] formats , final Locale locale ) { for ( final String format : formats ) { final SimpleDateFormat sdf = new SimpleDateFormat ( format , locale ) ; try { return sdf . parse ( datum ) ; } catch ( final ParseException e ) { // Do nothing... } } return null ; }
Returns a date - object if the array with the formats are valid otherwise null .