v1.2.22 新增万圣节、万圣节前夜;新增全国中小学生安全教育日;新增春社(原二月初二春社改为社日节)、秋社;优化代码。
This commit is contained in:
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.21</version>
|
||||
<version>1.2.22</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.21</version>
|
||||
<version>1.2.22</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.2.21</version>
|
||||
<version>1.2.22</version>
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
<url>https://github.com/6tail/lunar-java</url>
|
||||
<description>a calendar library for Solar and Chinese Lunar</description>
|
||||
|
||||
@@ -18,6 +18,7 @@ public class ExactDate {
|
||||
*/
|
||||
private static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT+8");
|
||||
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public static Calendar fromYmdHms(int year, int month, int day, int hour, int minute, int second) {
|
||||
Calendar c = Calendar.getInstance(TIME_ZONE);
|
||||
c.set(year, month - 1, day, hour, minute, second);
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Foto {
|
||||
/**
|
||||
* 阴历
|
||||
*/
|
||||
private Lunar lunar;
|
||||
private final Lunar lunar;
|
||||
|
||||
public Foto(Lunar lunar) {
|
||||
this.lunar = lunar;
|
||||
@@ -228,7 +228,7 @@ public class Foto {
|
||||
|
||||
public String toFullString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(toString());
|
||||
s.append(this);
|
||||
for (FotoFestival f : getFestivals()) {
|
||||
s.append(" (");
|
||||
s.append(f);
|
||||
|
||||
@@ -10,22 +10,22 @@ public class FotoFestival {
|
||||
/**
|
||||
* 是日何日,如:雷斋日
|
||||
*/
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 犯之因果,如:犯者夺纪
|
||||
*/
|
||||
private String result;
|
||||
private final String result;
|
||||
|
||||
/**
|
||||
* 是否每月同
|
||||
*/
|
||||
private boolean everyMonth;
|
||||
private final boolean everyMonth;
|
||||
|
||||
/**
|
||||
* 备注,如:宜先一日即戒
|
||||
*/
|
||||
private String remark;
|
||||
private final String remark;
|
||||
|
||||
public FotoFestival(String name, String result, boolean everyMonth, String remark) {
|
||||
this.name = name;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Lunar {
|
||||
/**
|
||||
* 对应阳历
|
||||
*/
|
||||
private Solar solar;
|
||||
private final Solar solar;
|
||||
/**
|
||||
* 时对应的天干下标,0-9
|
||||
*/
|
||||
@@ -116,15 +116,15 @@ public class Lunar {
|
||||
/**
|
||||
* 阳历小时
|
||||
*/
|
||||
private int hour;
|
||||
private final int hour;
|
||||
/**
|
||||
* 阳历分钟
|
||||
*/
|
||||
private int minute;
|
||||
private final int minute;
|
||||
/**
|
||||
* 阳历秒钟
|
||||
*/
|
||||
private int second;
|
||||
private final int second;
|
||||
/**
|
||||
* 八字
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ public class Lunar {
|
||||
/**
|
||||
* 24节气表(对应阳历的准确时刻)
|
||||
*/
|
||||
private Map<String, Solar> jieQi = new LinkedHashMap<String, Solar>();
|
||||
private final Map<String, Solar> jieQi = new LinkedHashMap<String, Solar>();
|
||||
|
||||
/**
|
||||
* 默认使用当前日期初始化
|
||||
@@ -191,7 +191,6 @@ public class Lunar {
|
||||
*
|
||||
* @param date 阳历日期
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public Lunar(Date date) {
|
||||
solar = new Solar(date);
|
||||
int currentYear = solar.getYear();
|
||||
@@ -968,9 +967,27 @@ public class Lunar {
|
||||
if (null != fs) {
|
||||
l.addAll(fs);
|
||||
}
|
||||
if (solar.toYmd().equals(jieQi.get("清明").next(-1).toYmd())) {
|
||||
String solarYmd = solar.toYmd();
|
||||
if (solarYmd.equals(jieQi.get("清明").next(-1).toYmd())) {
|
||||
l.add("寒食节");
|
||||
}
|
||||
Solar jq = jieQi.get("立春");
|
||||
int offset = 4 - jq.getLunar().getDayGanIndex();
|
||||
if (offset < 0) {
|
||||
offset += 10;
|
||||
}
|
||||
if (solarYmd.equals(jq.next(offset + 40).toYmd())) {
|
||||
l.add("春社");
|
||||
}
|
||||
|
||||
jq = jieQi.get("立秋");
|
||||
offset = 4 - jq.getLunar().getDayGanIndex();
|
||||
if (offset < 0) {
|
||||
offset += 10;
|
||||
}
|
||||
if (solarYmd.equals(jq.next(offset + 40).toYmd())) {
|
||||
l.add("秋社");
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -1292,14 +1309,12 @@ public class Lunar {
|
||||
public String getMonthPositionTaiSui(int sect) {
|
||||
int monthZhiIndex;
|
||||
int monthGanIndex;
|
||||
switch (sect) {
|
||||
case 3:
|
||||
monthZhiIndex = this.monthZhiIndexExact;
|
||||
monthGanIndex = this.monthGanIndexExact;
|
||||
break;
|
||||
default:
|
||||
monthZhiIndex = this.monthZhiIndex;
|
||||
monthGanIndex = this.monthGanIndex;
|
||||
if (sect == 3) {
|
||||
monthZhiIndex = this.monthZhiIndexExact;
|
||||
monthGanIndex = this.monthGanIndexExact;
|
||||
} else {
|
||||
monthZhiIndex = this.monthZhiIndex;
|
||||
monthGanIndex = this.monthGanIndex;
|
||||
}
|
||||
return getMonthPositionTaiSui(monthZhiIndex, monthGanIndex);
|
||||
}
|
||||
@@ -2458,7 +2473,7 @@ public class Lunar {
|
||||
|
||||
public String toFullString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(toString());
|
||||
s.append(this);
|
||||
s.append(" ");
|
||||
s.append(getYearInGanZhi());
|
||||
s.append("(");
|
||||
@@ -2862,7 +2877,6 @@ public class Lunar {
|
||||
*
|
||||
* @return 数九,如果不是数九天,返回null
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public ShuJiu getShuJiu() {
|
||||
Calendar currentCalendar = ExactDate.fromYmd(solar.getYear(), solar.getMonth(), solar.getDay());
|
||||
Solar start = jieQi.get("DONG_ZHI");
|
||||
@@ -2889,7 +2903,6 @@ public class Lunar {
|
||||
*
|
||||
* @return 三伏,如果不是伏天,返回null
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public Fu getFu() {
|
||||
Calendar currentCalendar = ExactDate.fromYmd(solar.getYear(), solar.getMonth(), solar.getDay());
|
||||
Solar xiaZhi = jieQi.get("夏至");
|
||||
@@ -2962,7 +2975,6 @@ public class Lunar {
|
||||
*
|
||||
* @return 物候
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public String getWuHou() {
|
||||
JieQi jieQi = getPrevJieQi(true);
|
||||
String name = jieQi.getName();
|
||||
|
||||
@@ -14,22 +14,22 @@ public class LunarMonth {
|
||||
/**
|
||||
* 农历年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 农历月:1-12,闰月为负数,如闰2月为-2
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 天数,大月30天,小月29天
|
||||
*/
|
||||
private int dayCount;
|
||||
private final int dayCount;
|
||||
|
||||
/**
|
||||
* 初一的儒略日
|
||||
*/
|
||||
private double firstJulianDay;
|
||||
private final double firstJulianDay;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
|
||||
@@ -15,17 +15,17 @@ public class LunarTime {
|
||||
/**
|
||||
* 天干下标,0-9
|
||||
*/
|
||||
private int ganIndex;
|
||||
private final int ganIndex;
|
||||
|
||||
/**
|
||||
* 地支下标,0-11
|
||||
*/
|
||||
private int zhiIndex;
|
||||
private final int zhiIndex;
|
||||
|
||||
/**
|
||||
* 阴历
|
||||
*/
|
||||
private Lunar lunar;
|
||||
private final Lunar lunar;
|
||||
|
||||
public LunarTime(int lunarYear, int lunarMonth, int lunarDay, int hour, int minute, int second) {
|
||||
this.lunar = Lunar.fromYmdHms(lunarYear, lunarMonth, lunarDay, hour, minute, second);
|
||||
@@ -316,10 +316,7 @@ public class LunarTime {
|
||||
//顺逆
|
||||
String solarYmd = lunar.getSolar().toYmd();
|
||||
Map<String, Solar> jieQi = lunar.getJieQiTable();
|
||||
boolean asc = false;
|
||||
if (solarYmd.compareTo(jieQi.get("冬至").toYmd()) >= 0 && solarYmd.compareTo(jieQi.get("夏至").toYmd()) < 0) {
|
||||
asc = true;
|
||||
}
|
||||
boolean asc = solarYmd.compareTo(jieQi.get("冬至").toYmd()) >= 0 && solarYmd.compareTo(jieQi.get("夏至").toYmd()) < 0;
|
||||
int start = asc ? 7 : 3;
|
||||
String dayZhi = lunar.getDayZhi();
|
||||
if ("子午卯酉".contains(dayZhi)) {
|
||||
|
||||
@@ -50,27 +50,27 @@ public class LunarYear {
|
||||
/**
|
||||
* 农历年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 天干下标
|
||||
*/
|
||||
private int ganIndex;
|
||||
private final int ganIndex;
|
||||
|
||||
/**
|
||||
* 地支下标
|
||||
*/
|
||||
private int zhiIndex;
|
||||
private final int zhiIndex;
|
||||
|
||||
/**
|
||||
* 农历月们
|
||||
*/
|
||||
private List<LunarMonth> months = new ArrayList<LunarMonth>();
|
||||
private final List<LunarMonth> months = new ArrayList<LunarMonth>();
|
||||
|
||||
/**
|
||||
* 节气儒略日们
|
||||
*/
|
||||
private List<Double> jieQiJulianDays = new ArrayList<Double>();
|
||||
private final List<Double> jieQiJulianDays = new ArrayList<Double>();
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
|
||||
@@ -19,34 +19,41 @@ public class Solar {
|
||||
* 2000年儒略日数(2000-1-1 12:00:00 UTC)
|
||||
*/
|
||||
public static final double J2000 = 2451545;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 日
|
||||
*/
|
||||
private int day;
|
||||
private final int day;
|
||||
|
||||
/**
|
||||
* 时
|
||||
*/
|
||||
private int hour;
|
||||
private final int hour;
|
||||
|
||||
/**
|
||||
* 分
|
||||
*/
|
||||
private int minute;
|
||||
private final int minute;
|
||||
|
||||
/**
|
||||
* 秒
|
||||
*/
|
||||
private int second;
|
||||
private final int second;
|
||||
|
||||
/**
|
||||
* 日历
|
||||
*/
|
||||
private Calendar calendar;
|
||||
private final Calendar calendar;
|
||||
|
||||
/**
|
||||
* 默认使用当前日期初始化
|
||||
@@ -76,7 +83,6 @@ public class Solar {
|
||||
* @param minute 分钟,0到59
|
||||
* @param second 秒钟,0到59
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public Solar(int year, int month, int day, int hour, int minute, int second) {
|
||||
calendar = ExactDate.fromYmdHms(year, month, day, hour, minute, second);
|
||||
this.year = year;
|
||||
@@ -123,7 +129,6 @@ public class Solar {
|
||||
*
|
||||
* @param julianDay 儒略日
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public Solar(double julianDay) {
|
||||
int d = (int) (julianDay + 0.5);
|
||||
double f = julianDay + 0.5 - d;
|
||||
@@ -381,6 +386,12 @@ public class Solar {
|
||||
if (null != f) {
|
||||
l.add(f);
|
||||
}
|
||||
if (day + 7 >= SolarUtil.getDaysOfMonth(year, month)) {
|
||||
f = SolarUtil.WEEK_FESTIVAL.get(month + "-0-" + week);
|
||||
if (null != f) {
|
||||
l.add(f);
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -515,10 +526,7 @@ public class Solar {
|
||||
int m = this.month;
|
||||
double d = this.day + ((this.second * 1D / 60 + this.minute) / 60 + this.hour) / 24;
|
||||
int n = 0;
|
||||
boolean g = false;
|
||||
if (y * 372 + m * 31 + (int) d >= 588829) {
|
||||
g = true;
|
||||
}
|
||||
boolean g = y * 372 + m * 31 + (int) d >= 588829;
|
||||
if (m <= 2) {
|
||||
m += 12;
|
||||
y--;
|
||||
@@ -595,7 +603,6 @@ public class Solar {
|
||||
* @param onlyWorkday 是否仅限工作日
|
||||
* @return 阳历日期
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public Solar next(int days, boolean onlyWorkday) {
|
||||
Calendar c = ExactDate.fromYmdHms(year, month, day, hour, minute, second);
|
||||
if (0 != days) {
|
||||
|
||||
@@ -14,11 +14,11 @@ public class SolarHalfYear {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 半年的月数
|
||||
@@ -124,7 +124,6 @@ public class SolarHalfYear {
|
||||
* @param halfYears 推移的半年数,负数为倒推
|
||||
* @return 推移后的半年
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public SolarHalfYear next(int halfYears) {
|
||||
if (0 == halfYears) {
|
||||
return new SolarHalfYear(year, month);
|
||||
|
||||
@@ -16,11 +16,11 @@ public class SolarMonth {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 默认当月
|
||||
@@ -128,7 +128,6 @@ public class SolarMonth {
|
||||
* @param months 月数
|
||||
* @return 阳历月
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public SolarMonth next(int months) {
|
||||
Calendar c = ExactDate.fromYmd(year, month, 1);
|
||||
c.add(Calendar.MONTH, months);
|
||||
|
||||
@@ -14,11 +14,13 @@ public class SolarSeason {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 一个季度的月数
|
||||
*/
|
||||
|
||||
@@ -16,19 +16,22 @@ public class SolarWeek {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
private int month;
|
||||
private final int month;
|
||||
|
||||
/**
|
||||
* 日
|
||||
*/
|
||||
private int day;
|
||||
private final int day;
|
||||
|
||||
/**
|
||||
* 星期几作为一周的开始,1234560分别代表星期一至星期天
|
||||
*/
|
||||
private int start;
|
||||
private final int start;
|
||||
|
||||
/**
|
||||
* 默认当月
|
||||
@@ -187,7 +190,6 @@ public class SolarWeek {
|
||||
* @param separateMonth 是否按月单独计算
|
||||
* @return 推移后的阳历周
|
||||
*/
|
||||
@SuppressWarnings("MagicConstant")
|
||||
public SolarWeek next(int weeks, boolean separateMonth) {
|
||||
if (0 == weeks) {
|
||||
return new SolarWeek(year, month, day, start);
|
||||
|
||||
@@ -14,7 +14,7 @@ public class SolarYear {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 一年的月数
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Tao {
|
||||
/**
|
||||
* 阴历
|
||||
*/
|
||||
private Lunar lunar;
|
||||
private final Lunar lunar;
|
||||
|
||||
public Tao(Lunar lunar) {
|
||||
this.lunar = lunar;
|
||||
|
||||
@@ -10,12 +10,12 @@ public class TaoFestival {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
private final String remark;
|
||||
|
||||
public TaoFestival(String name, String remark) {
|
||||
this.name = name;
|
||||
|
||||
@@ -12,28 +12,34 @@ public class DaYun {
|
||||
/**
|
||||
* 开始年(含)
|
||||
*/
|
||||
private int startYear;
|
||||
private final int startYear;
|
||||
|
||||
/**
|
||||
* 结束年(含)
|
||||
*/
|
||||
private int endYear;
|
||||
private final int endYear;
|
||||
|
||||
/**
|
||||
* 开始年龄(含)
|
||||
*/
|
||||
private int startAge;
|
||||
private final int startAge;
|
||||
|
||||
/**
|
||||
* 结束年龄(含)
|
||||
*/
|
||||
private int endAge;
|
||||
private final int endAge;
|
||||
|
||||
/**
|
||||
* 序数,0-9
|
||||
*/
|
||||
private int index;
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* 运
|
||||
*/
|
||||
private Yun yun;
|
||||
private Lunar lunar;
|
||||
private final Yun yun;
|
||||
|
||||
private final Lunar lunar;
|
||||
|
||||
public DaYun(Yun yun, int index) {
|
||||
this.yun = yun;
|
||||
|
||||
@@ -12,20 +12,24 @@ public class LiuNian {
|
||||
/**
|
||||
* 序数,0-9
|
||||
*/
|
||||
private int index;
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* 大运
|
||||
*/
|
||||
private DaYun daYun;
|
||||
private final DaYun daYun;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private int age;
|
||||
private Lunar lunar;
|
||||
private final int age;
|
||||
|
||||
private final Lunar lunar;
|
||||
|
||||
public LiuNian(DaYun daYun, int index) {
|
||||
this.daYun = daYun;
|
||||
|
||||
@@ -11,8 +11,9 @@ public class LiuYue {
|
||||
/**
|
||||
* 序数,0-9
|
||||
*/
|
||||
private int index;
|
||||
private LiuNian liuNian;
|
||||
private final int index;
|
||||
|
||||
private final LiuNian liuNian;
|
||||
|
||||
public LiuYue(LiuNian liuNian, int index) {
|
||||
this.liuNian = liuNian;
|
||||
|
||||
@@ -12,24 +12,29 @@ public class XiaoYun {
|
||||
/**
|
||||
* 序数,0-9
|
||||
*/
|
||||
private int index;
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* 大运
|
||||
*/
|
||||
private DaYun daYun;
|
||||
private final DaYun daYun;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private int year;
|
||||
private final int year;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private int age;
|
||||
private final int age;
|
||||
|
||||
/**
|
||||
* 是否顺推
|
||||
*/
|
||||
private boolean forward;
|
||||
private Lunar lunar;
|
||||
private final boolean forward;
|
||||
|
||||
private final Lunar lunar;
|
||||
|
||||
public XiaoYun(DaYun daYun, int index, boolean forward) {
|
||||
this.daYun = daYun;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Yun {
|
||||
/**
|
||||
* 性别(1男,0女)
|
||||
*/
|
||||
private int gender;
|
||||
private final int gender;
|
||||
|
||||
/**
|
||||
* 起运年数
|
||||
@@ -39,9 +39,9 @@ public class Yun {
|
||||
/**
|
||||
* 是否顺推
|
||||
*/
|
||||
private boolean forward;
|
||||
private final boolean forward;
|
||||
|
||||
private Lunar lunar;
|
||||
private final Lunar lunar;
|
||||
|
||||
/**
|
||||
* 使用默认流派1初始化运
|
||||
|
||||
@@ -152,7 +152,7 @@ public class LunarUtil{
|
||||
put("1-25",Collections.nCopies(1,"填仓节"));
|
||||
put("1-30",Collections.nCopies(1,"正月晦"));
|
||||
put("2-1",Collections.nCopies(1,"中和节"));
|
||||
put("2-2",Collections.nCopies(1,"春社"));
|
||||
put("2-2",Collections.nCopies(1,"社日节"));
|
||||
put("3-3",Collections.nCopies(1,"上巳节"));
|
||||
put("5-20",Collections.nCopies(1,"分龙节"));
|
||||
put("5-25",Collections.nCopies(1,"会龙节"));
|
||||
|
||||
@@ -42,6 +42,8 @@ public class SolarUtil {
|
||||
put("8-1", "建军节");
|
||||
put("9-10", "教师节");
|
||||
put("10-1", "国庆节");
|
||||
put("10-31", "万圣节前夜");
|
||||
put("11-1", "万圣节");
|
||||
put("12-24", "平安夜");
|
||||
put("12-25", "圣诞节");
|
||||
}
|
||||
@@ -53,6 +55,7 @@ public class SolarUtil {
|
||||
private static final long serialVersionUID = -1;
|
||||
|
||||
{
|
||||
put("3-0-1", "全国中小学生安全教育日");
|
||||
put("5-2-0", "母亲节");
|
||||
put("6-3-0", "父亲节");
|
||||
put("11-4-4", "感恩节");
|
||||
|
||||
@@ -333,4 +333,22 @@ public class GanZhiTest {
|
||||
Assert.assertEquals("丁丑",lunar.getMonthInGanZhiExact());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test19() {
|
||||
Solar solar = new Solar(2022,4,6,20,18,0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("壬寅",lunar.getYearInGanZhi());
|
||||
Assert.assertEquals("壬寅",lunar.getYearInGanZhiByLiChun());
|
||||
Assert.assertEquals("壬寅",lunar.getYearInGanZhiExact());
|
||||
|
||||
Assert.assertEquals("甲辰",lunar.getMonthInGanZhi());
|
||||
Assert.assertEquals("甲辰",lunar.getMonthInGanZhiExact());
|
||||
|
||||
Assert.assertEquals("己丑",lunar.getDayInGanZhi());
|
||||
Assert.assertEquals("己丑",lunar.getDayInGanZhiExact());
|
||||
Assert.assertEquals("己丑",lunar.getDayInGanZhiExact2());
|
||||
|
||||
Assert.assertEquals("甲戌",lunar.getTimeInGanZhi());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -424,4 +424,39 @@ public class LunarTest {
|
||||
Assert.assertEquals(4, lunar.getDayJi().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test57() {
|
||||
Solar solar = new Solar(1991, 2, 5);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("庚寅", lunar.getMonthInGanZhi());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test58() {
|
||||
Solar solar = new Solar(2021, 3, 21);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("春社", lunar.getOtherFestivals().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test59() {
|
||||
Solar solar = new Solar(2022, 3, 16);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("春社", lunar.getOtherFestivals().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test60() {
|
||||
Solar solar = new Solar(1722, 9, 25);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("秋社", lunar.getOtherFestivals().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test61() {
|
||||
Solar solar = new Solar(840, 9, 14);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("秋社", lunar.getOtherFestivals().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SolarTest {
|
||||
|
||||
@Test
|
||||
public void test10(){
|
||||
Assert.assertEquals(false, SolarUtil.isLeapYear(1500));
|
||||
Assert.assertFalse(SolarUtil.isLeapYear(1500));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,4 +73,10 @@ public class SolarTest {
|
||||
Assert.assertEquals("2020-01-19",date.next(1,true).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test11(){
|
||||
Solar solar = new Solar(2022, 3, 28);
|
||||
Assert.assertEquals("全国中小学生安全教育日",solar.getFestivals().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user