Class AgeDetail

java.lang.Object
cloud.opencode.base.date.between.AgeDetail

public final class AgeDetail extends Object
Detailed age information including statistics and milestones 详细年龄信息,包括统计数据和里程碑

This class provides comprehensive age-related information including total time lived in various units, life statistics, and milestone tracking.

此类提供全面的年龄相关信息,包括各种单位的生存时间总计、 生活统计数据和里程碑跟踪。

Features | 主要功能:

  • Total time in various units - 各种单位的总时间
  • Life percentage calculations - 生命百分比计算
  • Milestone tracking - 里程碑跟踪
  • Statistics (weekends, holidays lived) - 统计数据(周末、假期)

Usage Examples | 使用示例:

LocalDate birth = LocalDate.of(1990, 5, 15);
AgeDetail detail = AgeDetail.of(birth);

System.out.println(detail.getTotalDays());     // Total days lived
System.out.println(detail.getTotalWeekends()); // Total weekend days
System.out.println(detail.getNextMilestone()); // Next milestone age

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: Yes (with explicit null checks) - 空值安全: 是(有明确的空值检查)
Since:
JDK 25, opencode-base-date V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Gets the underlying AgeBetween 获取底层的AgeBetween
    int
    Gets the number of birthdays celebrated 获取庆祝的生日数
    Gets the season the person was born in 获取出生的季节
    Gets the season the person was born in (Chinese) 获取出生的季节(中文)
    long
    Gets the days until the next milestone birthday 获取距离下一个里程碑生日的天数
    int
    getEstimatedRemainingYears(int lifeExpectancy)
    Gets the estimated remaining years based on life expectancy 基于预期寿命获取估计的剩余年数
    long
    Gets the estimated total weekend days lived (faster calculation) 获取估计的周末天数(更快的计算)
    int
    Gets the last passed milestone age 获取上一个通过的里程碑年龄
    int
    Gets the number of leap years lived through 获取经历的闰年数
    double
    getLifePercentage(int lifeExpectancy)
    Gets the percentage of life lived based on average life expectancy 基于平均预期寿命获取已生存的百分比
    int
    Gets the next milestone age 获取下一个里程碑年龄
    Gets the date of the next milestone birthday 获取下一个里程碑生日的日期
    long
    Gets the total days lived 获取生存的总天数
    long
    Gets the total hours lived (approximate) 获取生存的总小时数(近似值)
    long
    Gets the total minutes lived (approximate) 获取生存的总分钟数(近似值)
    long
    Gets the total months lived 获取生存的总月数
    long
    Gets the total seconds lived (approximate) 获取生存的总秒数(近似值)
    long
    Gets the total number of weekend days lived 获取生存的周末天数总数
    long
    Gets the total weeks lived 获取生存的总周数
    int
     
    static AgeDetail
    of(AgeBetween ageBetween)
    Creates an AgeDetail from an AgeBetween 从AgeBetween创建AgeDetail
    static AgeDetail
    of(LocalDate birthDate)
    Creates an AgeDetail from a birth date 从出生日期创建AgeDetail
    static AgeDetail
    of(LocalDate birthDate, LocalDate referenceDate)
    Creates an AgeDetail from a birth date to a reference date 从出生日期到参考日期创建AgeDetail
     
    Creates a detailed summary 创建详细摘要

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • of

      public static AgeDetail of(AgeBetween ageBetween)
      Creates an AgeDetail from an AgeBetween 从AgeBetween创建AgeDetail
      Parameters:
      ageBetween - the AgeBetween | AgeBetween
      Returns:
      the AgeDetail instance | AgeDetail实例
    • of

      public static AgeDetail of(LocalDate birthDate)
      Creates an AgeDetail from a birth date 从出生日期创建AgeDetail
      Parameters:
      birthDate - the birth date | 出生日期
      Returns:
      the AgeDetail instance | AgeDetail实例
    • of

      public static AgeDetail of(LocalDate birthDate, LocalDate referenceDate)
      Creates an AgeDetail from a birth date to a reference date 从出生日期到参考日期创建AgeDetail
      Parameters:
      birthDate - the birth date | 出生日期
      referenceDate - the reference date | 参考日期
      Returns:
      the AgeDetail instance | AgeDetail实例
    • getTotalDays

      public long getTotalDays()
      Gets the total days lived 获取生存的总天数
      Returns:
      the total days | 总天数
    • getTotalWeeks

      public long getTotalWeeks()
      Gets the total weeks lived 获取生存的总周数
      Returns:
      the total weeks | 总周数
    • getTotalMonths

      public long getTotalMonths()
      Gets the total months lived 获取生存的总月数
      Returns:
      the total months | 总月数
    • getTotalHours

      public long getTotalHours()
      Gets the total hours lived (approximate) 获取生存的总小时数(近似值)
      Returns:
      the total hours | 总小时数
    • getTotalMinutes

      public long getTotalMinutes()
      Gets the total minutes lived (approximate) 获取生存的总分钟数(近似值)
      Returns:
      the total minutes | 总分钟数
    • getTotalSeconds

      public long getTotalSeconds()
      Gets the total seconds lived (approximate) 获取生存的总秒数(近似值)
      Returns:
      the total seconds | 总秒数
    • getTotalWeekends

      public long getTotalWeekends()
      Gets the total number of weekend days lived 获取生存的周末天数总数
      Returns:
      the total weekend days | 周末天数
    • getEstimatedWeekends

      public long getEstimatedWeekends()
      Gets the estimated total weekend days lived (faster calculation) 获取估计的周末天数(更快的计算)
      Returns:
      the estimated weekend days | 估计的周末天数
    • getLeapYearsLived

      public int getLeapYearsLived()
      Gets the number of leap years lived through 获取经历的闰年数
      Returns:
      the leap year count | 闰年数
    • getBirthdaysCelebrated

      public int getBirthdaysCelebrated()
      Gets the number of birthdays celebrated 获取庆祝的生日数
      Returns:
      the birthday count | 生日数
    • getNextMilestone

      public int getNextMilestone()
      Gets the next milestone age 获取下一个里程碑年龄
      Returns:
      the next milestone age, or -1 if none | 下一个里程碑年龄,如果没有则返回-1
    • getNextMilestoneDate

      public LocalDate getNextMilestoneDate()
      Gets the date of the next milestone birthday 获取下一个里程碑生日的日期
      Returns:
      the next milestone date, or null if none | 下一个里程碑日期,如果没有则返回null
    • getDaysUntilNextMilestone

      public long getDaysUntilNextMilestone()
      Gets the days until the next milestone birthday 获取距离下一个里程碑生日的天数
      Returns:
      the days until next milestone, or -1 if none | 距离下一个里程碑的天数,如果没有则返回-1
    • getLastMilestone

      public int getLastMilestone()
      Gets the last passed milestone age 获取上一个通过的里程碑年龄
      Returns:
      the last milestone age, or -1 if none | 上一个里程碑年龄,如果没有则返回-1
    • getBirthSeason

      public String getBirthSeason()
      Gets the season the person was born in 获取出生的季节
      Returns:
      the birth season | 出生季节
    • getBirthSeasonChinese

      public String getBirthSeasonChinese()
      Gets the season the person was born in (Chinese) 获取出生的季节(中文)
      Returns:
      the birth season in Chinese | 出生季节(中文)
    • getLifePercentage

      public double getLifePercentage(int lifeExpectancy)
      Gets the percentage of life lived based on average life expectancy 基于平均预期寿命获取已生存的百分比
      Parameters:
      lifeExpectancy - the life expectancy in years | 预期寿命(年)
      Returns:
      the percentage of life lived | 已生存的百分比
    • getEstimatedRemainingYears

      public int getEstimatedRemainingYears(int lifeExpectancy)
      Gets the estimated remaining years based on life expectancy 基于预期寿命获取估计的剩余年数
      Parameters:
      lifeExpectancy - the life expectancy in years | 预期寿命(年)
      Returns:
      the estimated remaining years | 估计的剩余年数
    • getAgeBetween

      public AgeBetween getAgeBetween()
      Gets the underlying AgeBetween 获取底层的AgeBetween
      Returns:
      the AgeBetween | AgeBetween
    • toSummary

      public String toSummary()
      Creates a detailed summary 创建详细摘要
      Returns:
      the summary string | 摘要字符串
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object