📌  相关文章
📜  计算java代码示例中两个日期之间的年数月数和天数

📅  最后修改于: 2022-03-11 14:52:27.853000             🧑  作者: Mango

代码示例3
LocalDate jamesBirthDay = new LocalDate(1955, 5, 19);
LocalDate now = new LocalDate(2015, 7, 30);
        
int monthsBetween = Months.monthsBetween(jamesBirthDay, now).getMonths();
int yearsBetween = Years.yearsBetween(jamesBirthDay, now).getYears();
        
System.out.println("Month since father of Java born : " 
                    + monthsBetween);
System.out.println("Number of years since father of Java born : " 
                    + yearsBetween);