Class Solar

java.lang.Object
org.aoju.bus.core.date.Solar

public class Solar extends Object
阳历日期
Since:
Java 17+
Author:
Kimi Liu
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    阳历月
    static class 
    阳历季度
    static class 
    阳历半年
    static class 
    阳历周
    static class 
    阳历年
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Map<String,String>
    日期对应的节日
    static final double
    2000年儒略日数(2000-1-1 12:00:00 UTC)
    static final Map<String,List<String>>
    日期对应的非正式节日
    static final Map<String,String>
    几月第几个星期几对应的节日
  • Constructor Summary

    Constructors
    Constructor
    Description
    默认使用当前日期初始化
    Solar(double julianDay)
    通过儒略日初始化
    Solar(int year, int month, int day)
    通过年月日初始化
    Solar(int year, int month, int day, int hour, int minute, int second)
    通过年月日初始化
    Solar(Calendar calendar)
    通过日历初始化
    Solar(Date date)
    通过日期初始化
  • Method Summary

    Modifier and Type
    Method
    Description
    build(boolean... args)
    构建字符串内容
    static Solar
    from(double julianDay)
    通过指定儒略日获取阳历
    static Solar
    from(int year, int month, int day)
    通过指定年月日获取阳历
    static Solar
    from(int year, int month, int day, int hour, int minute, int second)
    通过指定年月日时分获取阳历
    static List<Solar>
    from(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi)
    通过八字获取阳历列表(晚子时日柱按当天,起始年为1900)
    static List<Solar>
    from(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi, int sect)
    通过八字获取阳历列表(起始年为1900)
    static Solar
    from(Calendar calendar)
    通过指定日历获取阳历
    static Solar
    from(Date date)
    通过指定日期获取阳历
    static List<Solar>
    fromBaZi(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi, int sect, int baseYear)
    通过八字获取阳历列表(起始年为1900)
    int
    获取日期
    static int
    getDays(int ay, int am, int ad, int by, int bm, int bd)
    获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)
    static int
    getDays(Calendar calendar0, Calendar calendar1)
    获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)
    static int
    getDaysInYear(int year, int month, int day)
    获取某天为当年的第几天
    static int
    getDaysOfMonth(int year, int month)
    获取某年某月有多少天
    static int
    getDaysOfYear(int year)
    获取某年有多少天(平年365天,闰年366天)
    获取节日,有可能一天会有多个节日
    int
    获取小时
    double
    获取儒略日
    获取农历
    int
    获取分钟
    int
    获取月份
    获取非正式的节日,有可能一天会有多个节日
    int
    获取秒钟
    int
    获取星期,1代表周日
    获取星期的中文
    static int
    getWeeksOfMonth(int year, int month, int start)
    获取某年某月有多少周
    int
    获取年份
    获取星座
    boolean
    isAfter(Solar solar)
    是否在指定日期之后
    boolean
    isBefore(Solar solar)
    是否在指定日期之前
    boolean
    是否闰年
    static boolean
    isLeapYear(int year)
    是否闰年
    next(int days)
    获取往后推几天的阳历日期,如果要往前推,则天数用负数
    next(int days, boolean onlyWorkday)
    取往后推几天的阳历日期,如果要往前推,则天数用负数
    nextHour(int hours)
    小时推移
    nextMonth(int months)
    月推移
    nextYear(int years)
    年推移
    int
    subtract(Solar solar)
    阳历日期相减,获得相差天数
    int
    阳历日期相减,获得相差分钟数
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FESTIVAL

      public static final Map<String,String> FESTIVAL
      日期对应的节日
    • WEEK_FESTIVAL

      public static final Map<String,String> WEEK_FESTIVAL
      几月第几个星期几对应的节日
    • OTHER_FESTIVAL

      public static final Map<String,List<String>> OTHER_FESTIVAL
      日期对应的非正式节日
    • J2000

      public static final double J2000
      2000年儒略日数(2000-1-1 12:00:00 UTC)
      See Also:
  • Constructor Details

    • Solar

      public Solar()
      默认使用当前日期初始化
    • Solar

      public Solar(Date date)
      通过日期初始化
      Parameters:
      date - 日期
    • Solar

      public Solar(Calendar calendar)
      通过日历初始化
      Parameters:
      calendar - 日历
    • Solar

      public Solar(double julianDay)
      通过儒略日初始化
      Parameters:
      julianDay - 儒略日
    • Solar

      public Solar(int year, int month, int day, int hour, int minute, int second)
      通过年月日初始化
      Parameters:
      year - 年
      month - 月,1到12
      day - 日,1到31
      hour - 小时,0到23
      minute - 分钟,0到59
      second - 秒钟,0到59
    • Solar

      public Solar(int year, int month, int day)
      通过年月日初始化
      Parameters:
      year - 年
      month - 月,1到12
      day - 日,1到31
  • Method Details

    • from

      public static Solar from(Date date)
      通过指定日期获取阳历
      Parameters:
      date - 日期
      Returns:
      阳历
    • from

      public static Solar from(Calendar calendar)
      通过指定日历获取阳历
      Parameters:
      calendar - 日历
      Returns:
      阳历
    • from

      public static Solar from(double julianDay)
      通过指定儒略日获取阳历
      Parameters:
      julianDay - 儒略日
      Returns:
      阳历
    • from

      public static Solar from(int year, int month, int day)
      通过指定年月日获取阳历
      Parameters:
      year - 年
      month - 月,1到12
      day - 日,1到31
      Returns:
      阳历
    • from

      public static Solar from(int year, int month, int day, int hour, int minute, int second)
      通过指定年月日时分获取阳历
      Parameters:
      year - 年
      month - 月,1到12
      day - 日,1到31
      hour - 小时,0到23
      minute - 分钟,0到59
      second - 秒钟,0到59
      Returns:
      阳历
    • from

      public static List<Solar> from(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi)
      通过八字获取阳历列表(晚子时日柱按当天,起始年为1900)
      Parameters:
      yearGanZhi - 年柱
      monthGanZhi - 月柱
      dayGanZhi - 日柱
      timeGanZhi - 时柱
      Returns:
      符合的阳历列表
    • from

      public static List<Solar> from(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi, int sect)
      通过八字获取阳历列表(起始年为1900)
      Parameters:
      yearGanZhi - 年柱
      monthGanZhi - 月柱
      dayGanZhi - 日柱
      timeGanZhi - 时柱
      sect - 流派,2晚子时日柱按当天,1晚子时日柱按明天
      Returns:
      符合的阳历列表
    • fromBaZi

      public static List<Solar> fromBaZi(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi, int sect, int baseYear)
      通过八字获取阳历列表(起始年为1900)
      Parameters:
      yearGanZhi - 年柱
      monthGanZhi - 月柱
      dayGanZhi - 日柱
      timeGanZhi - 时柱
      sect - 流派,2晚子时日柱按当天,1晚子时日柱按明天
      baseYear - 起始年
      Returns:
      符合的阳历列表
    • isLeapYear

      public static boolean isLeapYear(int year)
      是否闰年
      Parameters:
      year - 年
      Returns:
      true/false 闰年/非闰年
    • getDaysOfYear

      public static int getDaysOfYear(int year)
      获取某年有多少天(平年365天,闰年366天)
      Parameters:
      year - 年
      Returns:
      天数
    • getDaysOfMonth

      public static int getDaysOfMonth(int year, int month)
      获取某年某月有多少天
      Parameters:
      year - 年
      month - 月
      Returns:
      天数
    • getDaysInYear

      public static int getDaysInYear(int year, int month, int day)
      获取某天为当年的第几天
      Parameters:
      year - 年
      month - 月
      day - 日
      Returns:
      第几天
    • getWeeksOfMonth

      public static int getWeeksOfMonth(int year, int month, int start)
      获取某年某月有多少周
      Parameters:
      year - 年
      month - 月
      start - 星期几作为一周的开始,默认星期日
      Returns:
      周数
    • getDays

      public static int getDays(int ay, int am, int ad, int by, int bm, int bd)
      获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)
      Parameters:
      ay - 年a
      am - 月a
      ad - 日a
      by - 年b
      bm - 月b
      bd - 日b
      Returns:
      天数
    • getDays

      public static int getDays(Calendar calendar0, Calendar calendar1)
      获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)
      Parameters:
      calendar0 - 日期a
      calendar1 - 日期b
      Returns:
      天数
    • isLeapYear

      public boolean isLeapYear()
      是否闰年
      Returns:
      true/false 闰年/非闰年
    • getWeek

      public int getWeek()
      获取星期,1代表周日
      Returns:
      1234567
    • getWeekInChinese

      public String getWeekInChinese()
      获取星期的中文
      Returns:
      星期x
    • getFestivals

      public List<String> getFestivals()
      获取节日,有可能一天会有多个节日
      Returns:
      劳动节等
    • getOtherFestivals

      public List<String> getOtherFestivals()
      获取非正式的节日,有可能一天会有多个节日
      Returns:
      非正式的节日列表,如中元节
    • getZodiac

      public String getZodiac()
      获取星座
      Returns:
      星座
    • getJulianDay

      public double getJulianDay()
      获取儒略日
      Returns:
      儒略日
    • next

      public Solar next(int days)
      获取往后推几天的阳历日期,如果要往前推,则天数用负数
      Parameters:
      days - 天数
      Returns:
      Solar
    • next

      public Solar next(int days, boolean onlyWorkday)
      取往后推几天的阳历日期,如果要往前推,则天数用负数
      Parameters:
      days - 天数
      onlyWorkday - 是否仅限工作日
      Returns:
      Solar
    • nextHour

      public Solar nextHour(int hours)
      小时推移
      Parameters:
      hours - 小时数
      Returns:
      阳历
    • getLunar

      public Lunar getLunar()
      获取农历
      Returns:
      农历
    • getYear

      public int getYear()
      获取年份
      Returns:
      如2020
    • getMonth

      public int getMonth()
      获取月份
      Returns:
      1到12
    • getDay

      public int getDay()
      获取日期
      Returns:
      1到31之间的数字
    • getHour

      public int getHour()
      获取小时
      Returns:
      0到23之间的数字
    • getMinute

      public int getMinute()
      获取分钟
      Returns:
      0到59之间的数字
    • getSecond

      public int getSecond()
      获取秒钟
      Returns:
      0到59之间的数字
    • toYmd

      public String toYmd()
    • subtract

      public int subtract(Solar solar)
      阳历日期相减,获得相差天数
      Parameters:
      solar - 阳历
      Returns:
      天数
    • subtractMinute

      public int subtractMinute(Solar solar)
      阳历日期相减,获得相差分钟数
      Parameters:
      solar - 阳历
      Returns:
      分钟数
    • isAfter

      public boolean isAfter(Solar solar)
      是否在指定日期之后
      Parameters:
      solar - 阳历
      Returns:
      true/false
    • isBefore

      public boolean isBefore(Solar solar)
      是否在指定日期之前
      Parameters:
      solar - 阳历
      Returns:
      true/false
    • nextYear

      public Solar nextYear(int years)
      年推移
      Parameters:
      years - 年数
      Returns:
      阳历
    • nextMonth

      public Solar nextMonth(int months)
      月推移
      Parameters:
      months - 月数
      Returns:
      阳历
    • build

      public String build(boolean... args)
      构建字符串内容
      Parameters:
      args - 可选参数-简化输出
      Returns:
      字符串内容