private static Date extractDate ( String text , Locale locale ) { DateFormat fmt ; for ( int style = 0 ; style <= 3 ; ++ style ) { // Date and time parsing for ( int style2 = 0 ; style2 <= 3 ; ++ style2 ) { fmt = DateFormat . getDateTimeInstance ( style , style2 , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } } // Date only parsing fmt = DateFormat . getDateInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } // Time only parsing fmt = DateFormat . getTimeInstance ( style , locale ) ; try { return fmt . parse ( text ) ; } catch ( ParseException exception ) { // } } return null ; }
Parse a date according to the specified locale .