/** * Attempts to parse a string containing a date representation using several different date * patterns. * * @param value String to parse * @return If the parsing was successful, returns the date value represented by the input value. * Otherwise, returns null. */ private static Date tryParse(String value) { for (Format format : Format.values()) { try { return format.parse(value); } catch (Exception e) {} } for (int i = 3; i >= 0; i--) { try { return DateFormat.getDateInstance(i).parse(value); } catch (Exception e) {} } return null; }