计算两个时间点的年月日

输出格式一:1年1月29天0小时0小时0秒

public static String calculateTimeDifferenceOne(Date startDate, Date endDate) {
    if (null == startDate || null == endDate) {
        return "";
    }
    ZoneId zoneId = ZoneId.systemDefault();
    LocalDateTime fromDateTime = LocalDateTime.ofInstant(startDate.toInstant(), zoneId);
    LocalDateTime toDateTime = LocalDateTime.ofInstant(endDate.toInstant(), zoneId);

    LocalDateTime tempDateTime = LocalDateTime.from(fromDateTime);
    // 年
    long years = tempDateTime.until(toDateTime, ChronoUnit.YEARS);
    tempDateTime = tempDateTime.plusYears(years);
    // 月
    long months = tempDateTime.until(toDateTime, ChronoUnit.MONTHS);
    tempDateTime = tempDateTime.plusMonths(months);
    // 日
    long days = tempDateTime.until(toDateTime, ChronoUnit.DAYS);
    tempDateTime = tempDateTime.plusDays(days);
    // 时
    long hours = tempDateTime.until(toDateTime, ChronoUnit.HOURS);
    tempDateTime = tempDateTime.plusHours(hours);
    // 分
    long minutes = tempDateTime.until(toDateTime, ChronoUnit.MINUTES);
    tempDateTime = tempDateTime.plusMinutes(minutes);
    // 秒
    long seconds = tempDateTime.until(toDateTime, ChronoUnit.SECONDS);

    return (0 == years ? "" : years + "年")
            + (0 == months ? "" : months + "月")
            + (0 == days ? "" : days + "天")
            + (hours + "小时")
            + (minutes + "小时")
            + (seconds + "秒");
}

输出格式二:1年13月425天10200小时612000小时36720000秒

public static String calculateTimeDifferenceTwo(Date startDate, Date endDate) {
    if (null == startDate || null == endDate) {
        return "";
    }
    ZoneId zoneId = ZoneId.systemDefault();
    LocalDateTime fromDateTime = LocalDateTime.ofInstant(startDate.toInstant(), zoneId);
    LocalDateTime toDateTime = LocalDateTime.ofInstant(endDate.toInstant(), zoneId);

    LocalDateTime tempDateTime = LocalDateTime.from(fromDateTime);
    // 年
    long years = tempDateTime.until(toDateTime, ChronoUnit.YEARS);
    // 月
    long months = tempDateTime.until(toDateTime, ChronoUnit.MONTHS);
    // 日
    long days = tempDateTime.until(toDateTime, ChronoUnit.DAYS);
    // 时
    long hours = tempDateTime.until(toDateTime, ChronoUnit.HOURS);
    // 分
    long minutes = tempDateTime.until(toDateTime, ChronoUnit.MINUTES);

    long seconds = tempDateTime.until(toDateTime, ChronoUnit.SECONDS);

    return (0 == years ? "" : years + "年")
            + (0 == months ? "" : months + "月")
            + (0 == days ? "" : days + "天")
            + (hours + "小时")
            + (minutes + "小时")
            + (seconds + "秒");
}