private static Date parse ( String date ) { for ( int i = 0 ; i < fmt . length ; i ++ ) { try { SimpleDateFormat df = new SimpleDateFormat ( fmt [ i ] ) ; return df . parse ( date ) ; } catch ( ParseException E ) { // keep trying } } throw new IllegalArgumentException ( date ) ; }
parse the date using the formats above . This is thread safe .