程序包 dev.utils.common

类 CalendarUtils

java.lang.Object
dev.utils.common.CalendarUtils

public final class CalendarUtils extends Object
detail: 日历工具类
作者:
Ttt
     公历、农历转换
另请参阅:
  • 字段详细资料

    • MIN_LUNAR_YEAR

      public static final int MIN_LUNAR_YEAR
      另请参阅:
    • MIN_SOLAR_YEAR

      public static final int MIN_SOLAR_YEAR
      另请参阅:
    • MAX_YEAR

      public static final int MAX_YEAR
      另请参阅:
  • 方法详细资料

    • isSupportLunar

      public static boolean isSupportLunar(int year)
      是否支持农历年份计算
      参数:
      year - 年份
      返回:
      true yes, false no
    • isSupportSolar

      public static boolean isSupportSolar(int year)
      是否支持公历年份计算
      参数:
      year - 年份
      返回:
      true yes, false no
    • solarToLunar

      public static int[] solarToLunar(int year, int month, int day)
      公历转农历
      参数:
      year - 公历年
      month - 公历月
      day - 公历日
      返回:
      [0] 农历年 [1] 农历月 [2] 农历日 [3] 是否闰月 0 false、1 true
    • lunarToSolar

      public static int[] lunarToSolar(int lunarYear, int lunarMonth, int lunarDay, boolean isLeap)
      农历转公历
      参数:
      lunarYear - 农历年
      lunarMonth - 农历月
      lunarDay - 农历日
      isLeap - 是否闰月
      返回:
      [0] 公历年 [1] 公历月 [2] 公历日
    • getLunarYearDays

      public static int getLunarYearDays(int year)
      获取农历年份总天数
      参数:
      year - 农历年
      返回:
      农历年份总天数
    • getLunarLeapDays

      public static int getLunarLeapDays(int year)
      获取农历年份闰月天数
      参数:
      year - 农历年
      返回:
      农历年份闰月天数
    • getLunarLeapMonth

      public static int getLunarLeapMonth(int year)
      获取农历年份哪个月是闰月
           返回 1 - 12 无闰月返回 0
       
      参数:
      year - 农历年
      返回:
      农历年份哪个月是闰月
    • getLunarMonthDays

      public static int getLunarMonthDays(int year, int month)
      获取农历年份与月份总天数
      参数:
      year - 农历年
      month - 农历月
      返回:
      农历年份与月份总天数
    • getLunarGanZhi

      public static String getLunarGanZhi(int year)
      获取干支历
      参数:
      year - 年份
      返回:
      干支历
    • getLunarMonthChinese

      public static String getLunarMonthChinese(int month, boolean isLeap)
      获取农历中文月份
      参数:
      month - 农历月
      isLeap - 是否闰月
      返回:
      农历中文月份
    • getLunarDayChinese

      public static String getLunarDayChinese(int day)
      获取农历中文天数
      参数:
      day - 天数
      返回:
      农历中文天数
    • getSolarTermsIndex

      public static int getSolarTermsIndex(int month, int day)
      获取二十四节气 ( 公历 ) 索引
      参数:
      month - 公历月
      day - 公历天
      返回:
      二十四节气 ( 公历 ) 索引
    • getSolarTerms

      public static String getSolarTerms(int month, int day)
      获取二十四节气 ( 公历 )
      参数:
      month - 公历月
      day - 公历天
      返回:
      二十四节气 ( 公历 )
    • getSolarTermsDate

      public static String getSolarTermsDate(int month, int day)
      获取二十四节气 ( 公历 ) 时间
      参数:
      month - 公历月
      day - 公历天
      返回:
      二十四节气 ( 公历 ) 时间
    • isFestival

      public static boolean isFestival(CalendarUtils.Festival festival, int year, int month, int day)
      校验是否相同节日
      参数:
      festival - 节日信息
      year - 年份
      month - 月份
      day - 天数
      返回:
      true yes, false no
    • isFestival

      public static boolean isFestival(CalendarUtils.Festival festival, int year, int month, int day, CalendarUtils.FestivalHook festivalHook)
      校验是否相同节日
      参数:
      festival - 节日信息
      year - 年份
      month - 月份
      day - 天数
      festivalHook - 节日 Hook 接口
      返回:
      true yes, false no
    • getFestival

      public static CalendarUtils.Festival getFestival(List<CalendarUtils.Festival> list, int year, int month, int day)
      获取符合条件的节日信息
      参数:
      list - 节日集合
      year - 年份
      month - 月份
      day - 天数
      返回:
      CalendarUtils.Festival
    • getFestival

      public static CalendarUtils.Festival getFestival(List<CalendarUtils.Festival> list, int year, int month, int day, CalendarUtils.FestivalHook festivalHook)
      获取符合条件的节日信息
           list 不能混合公历、农历节日防止判断出错
       
      参数:
      list - 节日集合
      year - 年份
      month - 月份
      day - 天数
      festivalHook - 节日 Hook 接口
      返回:
      CalendarUtils.Festival
    • getSolarFestival

      public static CalendarUtils.Festival getSolarFestival(int year, int month, int day)
      获取公历符合条件的节日信息
      参数:
      year - 年份
      month - 月份
      day - 天数
      返回:
      CalendarUtils.Festival
    • getLunarFestival

      public static CalendarUtils.Festival getLunarFestival(int year, int month, int day)
      获取农历符合条件的节日信息
      参数:
      year - 农历年
      month - 农历月
      day - 农历日
      返回:
      CalendarUtils.Festival
    • getFestivalHook

      public static CalendarUtils.FestivalHook getFestivalHook()
      获取节日 Hook 接口
      返回:
      CalendarUtils.FestivalHook
    • setFestivalHook

      public static void setFestivalHook(CalendarUtils.FestivalHook festivalHook)
      设置节日 Hook 接口
      参数:
      festivalHook - CalendarUtils.FestivalHook