Question: how to calculate number of months between 2 dates in java?
Answer: yearsBetween() method to calcualte the number of months and years between two dates in Java. LocalDate jamesBirthDay = new LocalDate(1955, 5, 19); LocalDate now = new LocalDate(2015, 7, 30); int monthsBetween = Months. monthsBetween(jamesBirthDay, now). getMonths(); int yearsBetween = Years.