public static Date parseDateLenient(String text) {
        if (text == null) {
            return null;
        }
        String normalized = normalize(text);
        for (DateTimeFormatter dateTimeFormatter : DATE_TIME_FORMATTERS) {
            try {
                ZonedDateTime zonedDateTime = ZonedDateTime.parse(normalized, dateTimeFormatter);
                return Date.from(Instant.from(zonedDateTime));
            } catch (SecurityException e) {
                throw e;
            } catch (DateTimeParseException e) {

                //There's a bug in java 8 that if we include .withZone in the DateTimeFormatter,
                //that will override the offset/timezone id even if it included
                // in the original string.  This is fixed in later versions of Java.
                // Once we move to Java 11, we can get rid of this. Can't make this up...
                try {
                    LocalDateTime localDateTime = LocalDateTime.parse(normalized, dateTimeFormatter);
                    return Date.from(Instant.from(localDateTime.atOffset(UTC)));
                } catch (SecurityException e2) {
                    throw e2;
                } catch (Exception e2) {
                    //swallow
                }
            } catch (Exception e) {
                //can get StringIndexOutOfBoundsException because of a bug in java 8
                //ignore
            }
        }

        for (DateTimeFormatter dateFormatter : DATE_FORMATTERS) {
            try {
                TemporalAccessor temporalAccessor = dateFormatter.parse(normalized);
                ZonedDateTime localDate = LocalDate.from(temporalAccessor)
                        .atStartOfDay()
                        .atZone(MIDDAY.toZoneId());
                return Date.from(Instant.from(localDate));
            } catch (SecurityException e) {
                throw e;
            } catch (Exception e) {
                //ignore
            }
        }
        return null;
    }
@Test
    public void testTrickyDates() throws Exception {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd", new DateFormatSymbols(Locale.US));
        //make sure there are no mis-parses of e.g. 90 = year 90 A.D, not 1990
        Date date1980 = df.parse("1980-01-01");
        Date date2010 = df.parse("2010-01-01");
        for (String dateString : new String[]{
                "11/14/08",
                "1/14/08",
                "1/2/08",
                "12/1/2008",
                "12/02/1996",
                "96/1/02",
                "96/12/02",
                "96/12/2",
                "1996/12/02",
                "Mon, 29 Jan 96 14:02 GMT",
                "7/20/95 1:12PM",
                "08/14/2000  12:48 AM",
                "8/4/2000  1:48 AM",
                "06/24/2008, Tuesday, 11 AM",
                }) {
            Date parsedDate = MailDateParser.parseDateLenient(dateString);
            assertNotNull(parsedDate);
            if (parsedDate != null) {
                assertTrue(parsedDate.getTime() > date1980.getTime(),
                        "date must be after 1980:" + dateString + " >> + " +
                                parsedDate);
                assertTrue(parsedDate.getTime() < date2010.getTime(),
                        "date must be before 2020: " + dateString + " >> + " +
                                parsedDate);
            }
        }
        //TODO: mime4j misparses these to pre 1980 dates
        //"Wed, 27 Dec 95 11:20:40 EST",
        //"26 Aug 00 11:14:52 EDT"
        //
        //We are still misparsing: 8/1/03 to a pre 1980 date

    }