📜  java 查找两个日期之间的时间 - Java 代码示例

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

代码示例1
public static String getAge(String birthdate) throws ParseException {
        LocalDate parsed = LocalDate.parse("1970-01-01");
        LocalDate current = LocalDate.now();
        
        Period p = Period.between(parsed, current);

          // Returns time between date and now
        return p.getYears() + " Years, " + p.getMonths() + " Months, " + p.getDays() + " Days";
    }