I am working on a school assignment and I am just stuck with the logic on this. Basically need to validate a RegEx (date) of years between 1900 and 2099. The days cannot exceed the maximum month days; (ie. June has 30 days so 31 is invalid) as well as account for leap years where the February date can be 29. Here is what I have so far but I keep getting validation errors from when the code is ran in the TestHarness. I think I have way to much logic here but not sure how to resolve. Any help would be awesome.

```
    public class RegexValidator {
            //class variables
            private String DATE_REGEX = "^((19|20)\\d\\d)-(0?[1-9]|
            1[012])-(0?[1-9]|[12][0-9]|3[01])$";

    public RegexValidator() {
            m_datePattern.compile(DATE_REGEX);
    }

    public boolean validDate(String date) {

        Matcher matcher = m_datePattern.matcher(date);

        int year = Integer.parseInt(matcher.group(1));//parse to calculate leap
        String month = matcher.group(2);
        String day = matcher.group(3);

        if(matcher.matches()) {
            matcher.reset();

            if(matcher.find()) {

                if(day.equals("31") && (month.equals("4") || month.equals("04") ||
                month.equals("6") || month.equals("06") || month.equals("9") ||
                month.equals("09") || month.equals("11"))) {
                    return false;
                } else if(month.equals("2") || month.equals("02")) {
                    //accounts for leap year
                    if(year % 4 == 0) {
                        if(day.equals("30") || day.equals("31")) {
                            return false;
                        } else {
                            return true;
                        }
                    } else {
                        if(day.equals("29") || day.equals("30") || day.equals("31")) {
                            return false;
                        } else {
                            return true;
                        }
                    }
                } else {
                    return true;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }

    }

```

Here is a list of the errors I am getting:

```
    Error validating date '1900-1-11'

Error validating date '1900-1-11'

 ---- test date 1892-02-29 - expected false
 ---- Exception calling validDate: null
 ---- test date 1976-02-29 - expected true
 ---- Exception calling validDate: null
Error validating date '1976-02-29'

Error validating date '1976-02-29'

 ---- test date 2001-02-29 - expected false
 ---- Exception calling validDate: null
 ---- test date 2002-13-02 - expected false
 ---- Exception calling validDate: null
 ---- test date 2003-01-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2003-01-31'

Error validating date '2003-01-31'

 ---- test date 1964-03-31 - expected true
 ---- Exception calling validDate: null
Error validating date '1964-03-31'

Error validating date '1964-03-31'

 ---- test date 1965-4-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 1954-4-30 - expected true
 ---- Exception calling validDate: null
Error validating date '1954-4-30'

Error validating date '1954-4-30'

 ---- test date 1901-5-33 - expected false
 ---- Exception calling validDate: null
 ---- test date 1901-5-15 - expected true
 ---- Exception calling validDate: null
Error validating date '1901-5-15'

Error validating date '1901-5-15'

 ---- test date 2016-05-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2016-05-31'

Error validating date '2016-05-31'

 ---- test date 2006-06-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 20016-06-29 - expected false
 ---- Exception calling validDate: null
 ---- test date 1934-7-4 - expected true
 ---- Exception calling validDate: null
Error validating date '1934-7-4'

Error validating date '1934-7-4'

 ---- test date 2016-07-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2016-07-31'

Error validating date '2016-07-31'

 ---- test date 2011-8-19 - expected true
 ---- Exception calling validDate: null
Error validating date '2011-8-19'

Error validating date '2011-8-19'

 ---- test date 2111-8-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 2011-09-30 - expected true
 ---- Exception calling validDate: null
Error validating date '2011-09-30'

Error validating date '2011-09-30'

 ---- test date 2111-9-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 2011-10-1 - expected true
 ---- Exception calling validDate: null
Error validating date '2011-10-1'

Error validating date '2011-10-1'

 ---- test date 2111-10-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 2001-10-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2001-10-31'

Error validating date '2001-10-31'

 ---- test date 2111-10-33 - expected false
 ---- Exception calling validDate: null
 ---- test date 2111-11-30 - expected false
 ---- Exception calling validDate: null
 ---- test date 2013-11-30 - expected true
 ---- Exception calling validDate: null
Error validating date '2013-11-30'

Error validating date '2013-11-30'

 ---- test date 2111-11-31 - expected false
 ---- Exception calling validDate: null
 ---- test date 2011-12-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2011-12-31'

Error validating date '2011-12-31'

 ---- test date 2099-12-31 - expected true
 ---- Exception calling validDate: null
Error validating date '2099-12-31'

Error validating date '2099-12-31'

```