Package org.aoju.bus.core.date
Class Solar
java.lang.Object
org.aoju.bus.core.date.Solar
阳历日期
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class阳历月static class阳历季度static class阳历半年static class阳历周static class阳历年 -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(boolean... args) 构建字符串内容static Solarfrom(double julianDay) 通过指定儒略日获取阳历static Solarfrom(int year, int month, int day) 通过指定年月日获取阳历static Solarfrom(int year, int month, int day, int hour, int minute, int second) 通过指定年月日时分获取阳历通过八字获取阳历列表(晚子时日柱按当天,起始年为1900)通过八字获取阳历列表(起始年为1900)static Solar通过指定日历获取阳历static Solar通过指定日期获取阳历fromBaZi(String yearGanZhi, String monthGanZhi, String dayGanZhi, String timeGanZhi, int sect, int baseYear) 通过八字获取阳历列表(起始年为1900)intgetDay()获取日期static intgetDays(int ay, int am, int ad, int by, int bm, int bd) 获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)static int获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)static intgetDaysInYear(int year, int month, int day) 获取某天为当年的第几天static intgetDaysOfMonth(int year, int month) 获取某年某月有多少天static intgetDaysOfYear(int year) 获取某年有多少天(平年365天,闰年366天)获取节日,有可能一天会有多个节日intgetHour()获取小时double获取儒略日getLunar()获取农历int获取分钟intgetMonth()获取月份获取非正式的节日,有可能一天会有多个节日int获取秒钟intgetWeek()获取星期,1代表周日获取星期的中文static intgetWeeksOfMonth(int year, int month, int start) 获取某年某月有多少周intgetYear()获取年份获取星座boolean是否在指定日期之后boolean是否在指定日期之前boolean是否闰年static booleanisLeapYear(int year) 是否闰年next(int days) 获取往后推几天的阳历日期,如果要往前推,则天数用负数next(int days, boolean onlyWorkday) 取往后推几天的阳历日期,如果要往前推,则天数用负数nextHour(int hours) 小时推移nextMonth(int months) 月推移nextYear(int years) 年推移int阳历日期相减,获得相差天数intsubtractMinute(Solar solar) 阳历日期相减,获得相差分钟数toYmd()
-
Field Details
-
FESTIVAL
日期对应的节日 -
WEEK_FESTIVAL
几月第几个星期几对应的节日 -
OTHER_FESTIVAL
日期对应的非正式节日 -
J2000
public static final double J20002000年儒略日数(2000-1-1 12:00:00 UTC)- See Also:
-
-
Constructor Details
-
Solar
public Solar()默认使用当前日期初始化 -
Solar
通过日期初始化- Parameters:
date- 日期
-
Solar
通过日历初始化- 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到12day- 日,1到31hour- 小时,0到23minute- 分钟,0到59second- 秒钟,0到59
-
Solar
public Solar(int year, int month, int day) 通过年月日初始化- Parameters:
year- 年month- 月,1到12day- 日,1到31
-
-
Method Details
-
from
通过指定日期获取阳历- Parameters:
date- 日期- Returns:
- 阳历
-
from
通过指定日历获取阳历- Parameters:
calendar- 日历- Returns:
- 阳历
-
from
通过指定儒略日获取阳历- Parameters:
julianDay- 儒略日- Returns:
- 阳历
-
from
通过指定年月日获取阳历- Parameters:
year- 年month- 月,1到12day- 日,1到31- Returns:
- 阳历
-
from
通过指定年月日时分获取阳历- Parameters:
year- 年month- 月,1到12day- 日,1到31hour- 小时,0到23minute- 分钟,0到59second- 秒钟,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- 年aam- 月aad- 日aby- 年bbm- 月bbd- 日b- Returns:
- 天数
-
getDays
获取两个日期之间相差的天数(如果日期a比日期b小,天数为正,如果日期a比日期b大,天数为负)- Parameters:
calendar0- 日期acalendar1- 日期b- Returns:
- 天数
-
isLeapYear
public boolean isLeapYear()是否闰年- Returns:
- true/false 闰年/非闰年
-
getWeek
public int getWeek()获取星期,1代表周日- Returns:
- 1234567
-
getWeekInChinese
获取星期的中文- Returns:
- 星期x
-
getFestivals
获取节日,有可能一天会有多个节日- Returns:
- 劳动节等
-
getOtherFestivals
获取非正式的节日,有可能一天会有多个节日- Returns:
- 非正式的节日列表,如中元节
-
getZodiac
获取星座- Returns:
- 星座
-
getJulianDay
public double getJulianDay()获取儒略日- Returns:
- 儒略日
-
next
获取往后推几天的阳历日期,如果要往前推,则天数用负数- Parameters:
days- 天数- Returns:
Solar
-
next
取往后推几天的阳历日期,如果要往前推,则天数用负数- Parameters:
days- 天数onlyWorkday- 是否仅限工作日- Returns:
Solar
-
nextHour
小时推移- Parameters:
hours- 小时数- Returns:
- 阳历
-
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
-
subtract
阳历日期相减,获得相差天数- Parameters:
solar- 阳历- Returns:
- 天数
-
subtractMinute
阳历日期相减,获得相差分钟数- Parameters:
solar- 阳历- Returns:
- 分钟数
-
isAfter
是否在指定日期之后- Parameters:
solar- 阳历- Returns:
- true/false
-
isBefore
是否在指定日期之前- Parameters:
solar- 阳历- Returns:
- true/false
-
nextYear
年推移- Parameters:
years- 年数- Returns:
- 阳历
-
nextMonth
月推移- Parameters:
months- 月数- Returns:
- 阳历
-
build
构建字符串内容- Parameters:
args- 可选参数-简化输出- Returns:
- 字符串内容
-