Question: how to calculate difference in months between two 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.