I removed the previously accepted answer, after reading about your requirements in the comments: You want to calculate the difference in exact calendar years and were unsure of how to handle leap years.
The requirements will be the following:
2015-02-12
and 2016-02-12
: difference 1 year
2015-02-12
and 2017-02-12
: difference 2 years
2016-02-29
and 2018-02-28
: difference 2 years
2016-02-29
and 2020-02-29
: difference 4 years
The above should cover all edge cases. It means that adding exactly one year to the leap day of a leap year (for example February 29, 2016) will return February 28 (2017 as per the example). Most frameworks (Joda and .NET, which I checked) handle it this way.
One would expect that adding one year to the leap day (for ex. February 29, 2016) should yield March 1 instead of February 28 because 2016 has 366 days and the day which would have been February 29 in the next year is March 1, but it doesn't seem to be the case in the different implementations I saw.
I would suggest you stick to the frameworks' way of doing things.
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd.MM.yyyy");
final LocalDate start = formatter.parseLocalDate("29.02.2016");
final LocalDate end = formatter.parseLocalDate("28.02.2019");
Period period = new Period(start, end, PeriodType.yearMonthDay());
boolean exactlyMultipleOfYears = period.getDays() == 0 && period.getMonths() == 0 && period.getYears() > 0;