Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
954c841944 | ||
|
|
1cff6441f7 | ||
|
|
622294e74b | ||
|
|
12a4bb0efa | ||
|
|
6abe5ae1a2 | ||
|
|
135d39b751 | ||
|
|
85d56e5c3b | ||
|
|
b7fac53a81 | ||
|
|
72c4d0df71 | ||
|
|
10beaefd34 | ||
|
|
f1be26456d | ||
|
|
cc9444aa03 | ||
|
|
df6119c19e | ||
|
|
c7cd454f2d | ||
|
|
5680eb8d44 | ||
|
|
392ac5b00a | ||
|
|
9ec735cd4b | ||
|
|
e06c7a0532 | ||
|
|
bd18254834 | ||
|
|
28dbf8f45f | ||
|
|
0d1f64664e |
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
|
||||
### 下载jar
|
||||
|
||||
如果使用jar,建议下载最新的SNAPSHOT版本,bug将得到及时的修复。
|
||||
如果使用jar,建议下载最新的版本,bug将得到及时的修复。
|
||||
|
||||
[Download](https://github.com/6tail/lunar-java/releases)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.12</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ lunar is a calendar library for Solar and Chinese Lunar.
|
||||
|
||||
### Download
|
||||
|
||||
If you will use jars in your projects, I suggest you to download latest snapshot versions with less bugs.
|
||||
If you will use jars in your projects, I suggest you to download latest versions with less bugs.
|
||||
|
||||
[Download](https://github.com/6tail/lunar-java/releases)
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.12</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>
|
||||
|
||||
@@ -524,5 +524,67 @@ public class EightChar {
|
||||
return new Yun(this, gender);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年柱所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getYearXun(){
|
||||
return lunar.getYearXunExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年柱旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getYearXunKong(){
|
||||
return lunar.getYearXunKongExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月柱所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getMonthXun(){
|
||||
return lunar.getMonthXunExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月柱旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getMonthXunKong(){
|
||||
return lunar.getMonthXunKongExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日柱所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getDayXun(){
|
||||
return lunar.getDayXunExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日柱旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getDayXunKong(){
|
||||
return lunar.getDayXunKongExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时柱所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getTimeXun(){
|
||||
return lunar.getTimeXun();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时柱旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getTimeXunKong(){
|
||||
return lunar.getTimeXunKong();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@ public class Lunar{
|
||||
public static final String JIE_QI_FIRST = "冬至";
|
||||
/** 农历年末节气名(节令:大雪) */
|
||||
public static final String JIE_QI_LAST = "大雪";
|
||||
/** 节气表尾部追加阳历下年初的第一个节气名(节令:小寒),以示区分 */
|
||||
public static final String JIE_APPEND_SOLAR_FIRST = "XIAO_HAN";
|
||||
/** 节气表尾部追加阳历下年初的第二个节气名(气令:大寒),以示区分 */
|
||||
public static final String QI_APPEND_SOLAR_SECOND = "DA_HAN";
|
||||
/** 阳历下年初的第一个节气名(节令:小寒) */
|
||||
public static final String JIE_SOLAR_FIRST = "小寒";
|
||||
/** 阳历下年初的第二个节气名(气令:大寒) */
|
||||
public static final String QI_SOLAR_SECOND = "大寒";
|
||||
/** 1弧度对应的角秒 */
|
||||
private static final double SECOND_PER_RAD = 180 * 3600 / Math.PI;
|
||||
/** 节气表,国标以冬至为首个节气 */
|
||||
@@ -315,7 +323,7 @@ public class Lunar{
|
||||
t -= (53 * t * t + 334116 * Math.cos(4.67 + 628.307585 * t) + 2061 * Math.cos(2.678 + 628.3076 * t) * t) / v / 10000000;
|
||||
l = 48950621.66 + 6283319653.318 * t + 53 * t * t + 334166 * Math.cos(4.669257 + 628.307585 * t) + 3489 * Math.cos(4.6261 + 1256.61517 * t) + 2060.6 * Math.cos(2.67823 + 628.307585 * t) * t - 994 - 834 * Math.sin(2.1824 - 33.75705 * t);
|
||||
t -= (l / 10000000 - w) / 628.332 + (32 * (t + 1.8) * (t + 1.8) - 20) / 86400 / 36525;
|
||||
return t * 36525 + 8 / 24;
|
||||
return t * 36525 + 8D / 24;
|
||||
}
|
||||
|
||||
private double saLonT2(double w){
|
||||
@@ -328,10 +336,10 @@ public class Lunar{
|
||||
|
||||
private double qiHigh(double w){
|
||||
double t = saLonT2(w) * 36525;
|
||||
t = t - dtT(t) + 8 / 24;
|
||||
t = t - dtT(t) + 8D / 24;
|
||||
double v = ((t + 0.5) % 1) * 86400;
|
||||
if (v < 1200 || v > 86400 - 1200){
|
||||
t = saLonT(w) * 36525 - dtT(t) + 8 / 24;
|
||||
t = saLonT(w) * 36525 - dtT(t) + 8D / 24;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@@ -373,7 +381,7 @@ public class Lunar{
|
||||
|
||||
private double qiAccurate(double w){
|
||||
double t = saLonT(w) * 36525;
|
||||
return t - dtT(t) + 8 * 1D / 24;
|
||||
return t - dtT(t) + 8D / 24;
|
||||
}
|
||||
|
||||
private double qiAccurate2(double jd) {
|
||||
@@ -408,6 +416,16 @@ public class Lunar{
|
||||
//追加下一农历年初的冬至
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(JIE_QI_APPEND, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
|
||||
//追加下一阳历年初的小寒
|
||||
size++;
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(JIE_APPEND_SOLAR_FIRST, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
|
||||
//追加下一阳历年初的大寒
|
||||
size++;
|
||||
q = calcJieQi(w + 15.2184 * size);
|
||||
jieQi.put(QI_APPEND_SOLAR_SECOND, Solar.fromJulianDay(qiAccurate2(q) + Solar.J2000));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,6 +997,11 @@ public class Lunar{
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_QI_LAST;
|
||||
}
|
||||
// 追加的节令:小寒
|
||||
d = jieQi.get(JIE_APPEND_SOLAR_FIRST);
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_SOLAR_FIRST;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -999,6 +1022,11 @@ public class Lunar{
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return JIE_QI_FIRST;
|
||||
}
|
||||
// 追加的气令:大寒
|
||||
d = jieQi.get(QI_APPEND_SOLAR_SECOND);
|
||||
if(d.getYear()==solar.getYear()&&d.getMonth()==solar.getMonth()&&d.getDay()==solar.getDay()){
|
||||
return QI_SOLAR_SECOND;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1875,8 +1903,11 @@ public class Lunar{
|
||||
}
|
||||
// 寅月起,所以需要-2
|
||||
int monthIndex = monthZhiIndex-2;
|
||||
if(monthIndex<0){
|
||||
monthIndex += 12;
|
||||
}
|
||||
int index = start-monthIndex-1;
|
||||
if(index<0){
|
||||
while(index<0){
|
||||
index += 9;
|
||||
}
|
||||
return new NineStar(index);
|
||||
@@ -2030,6 +2061,12 @@ public class Lunar{
|
||||
if(JIE_QI_PREPEND.equals(jq)){
|
||||
jq = JIE_QI_LAST;
|
||||
}
|
||||
if(JIE_APPEND_SOLAR_FIRST.equals(jq)){
|
||||
jq = JIE_SOLAR_FIRST;
|
||||
}
|
||||
if(QI_APPEND_SOLAR_SECOND.equals(jq)){
|
||||
jq = QI_SOLAR_SECOND;
|
||||
}
|
||||
if(filter){
|
||||
if(!filters.contains(jq)){
|
||||
continue;
|
||||
@@ -2078,6 +2115,10 @@ public class Lunar{
|
||||
name = JIE_QI_FIRST;
|
||||
}else if(JIE_QI_PREPEND.equals(name)){
|
||||
name = JIE_QI_LAST;
|
||||
}else if(JIE_APPEND_SOLAR_FIRST.equals(name)){
|
||||
name = JIE_SOLAR_FIRST;
|
||||
}else if(QI_APPEND_SOLAR_SECOND.equals(name)){
|
||||
name = QI_SOLAR_SECOND;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -2348,4 +2389,132 @@ public class Lunar{
|
||||
}
|
||||
return new Lunar(y,m,d,hour,minute,second);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年所在旬(以正月初一作为新年的开始)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getYearXun(){
|
||||
return LunarUtil.getXun(getYearInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年所在旬(以立春当天作为新年的开始)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getYearXunByLiChun(){
|
||||
return LunarUtil.getXun(getYearInGanZhiByLiChun());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年所在旬(以立春交接时刻作为新年的开始)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getYearXunExact(){
|
||||
return LunarUtil.getXun(getYearInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值年空亡(以正月初一作为新年的开始)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getYearXunKong(){
|
||||
return LunarUtil.getXunKong(getYearInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值年空亡(以立春当天作为新年的开始)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getYearXunKongByLiChun(){
|
||||
return LunarUtil.getXunKong(getYearInGanZhiByLiChun());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值年空亡(以立春交接时刻作为新年的开始)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getYearXunKongExact(){
|
||||
return LunarUtil.getXunKong(getYearInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月所在旬(以节交接当天起算)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getMonthXun(){
|
||||
return LunarUtil.getXun(getMonthInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取月所在旬(以节交接时刻起算)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getMonthXunExact(){
|
||||
return LunarUtil.getXun(getMonthInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值月空亡(以节交接当天起算)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getMonthXunKong(){
|
||||
return LunarUtil.getXunKong(getMonthInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值月空亡(以节交接时刻起算)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getMonthXunKongExact(){
|
||||
return LunarUtil.getXunKong(getMonthInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日所在旬(以节交接当天起算)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getDayXun(){
|
||||
return LunarUtil.getXun(getDayInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日所在旬(晚子时算第二天)
|
||||
* @return 旬
|
||||
*/
|
||||
public String getDayXunExact(){
|
||||
return LunarUtil.getXun(getDayInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值日空亡
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getDayXunKong(){
|
||||
return LunarUtil.getXunKong(getDayInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值日空亡(晚子时算第二天)
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getDayXunKongExact(){
|
||||
return LunarUtil.getXunKong(getDayInGanZhiExact());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时辰所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getTimeXun(){
|
||||
return LunarUtil.getXun(getTimeInGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值时空亡
|
||||
* @return 空亡(旬空)
|
||||
*/
|
||||
public String getTimeXunKong(){
|
||||
return LunarUtil.getXunKong(getTimeInGanZhi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.nlf.calendar.util.HolidayUtil;
|
||||
import com.nlf.calendar.util.LunarUtil;
|
||||
import com.nlf.calendar.util.SolarUtil;
|
||||
|
||||
@@ -323,15 +324,10 @@ public class Solar{
|
||||
l.add(f);
|
||||
}
|
||||
//计算几月第几个星期几对应的节日
|
||||
//第几周
|
||||
int weekInMonth = calendar.get(Calendar.WEEK_OF_MONTH);
|
||||
int weeks = (int)Math.ceil(day/7D);
|
||||
//星期几,0代表星期天
|
||||
int week = getWeek();
|
||||
//星期天很奇葩,会多算一周,需要减掉
|
||||
if(0==week){
|
||||
weekInMonth--;
|
||||
}
|
||||
f = SolarUtil.WEEK_FESTIVAL.get(month+"-"+weekInMonth+"-"+week);
|
||||
f = SolarUtil.WEEK_FESTIVAL.get(month+"-"+weeks+"-"+week);
|
||||
if(null!=f){
|
||||
l.add(f);
|
||||
}
|
||||
@@ -536,9 +532,36 @@ public class Solar{
|
||||
* @return 阳历日期
|
||||
*/
|
||||
public Solar next(int days){
|
||||
return next(days,false);
|
||||
}
|
||||
|
||||
public Solar next(int days, boolean onlyWorkday){
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(year,month-1,day,hour,minute,second);
|
||||
c.add(Calendar.DATE,days);
|
||||
if(0!=days) {
|
||||
if(!onlyWorkday){
|
||||
c.add(Calendar.DATE,days);
|
||||
}else {
|
||||
int rest = Math.abs(days);
|
||||
int add = days < 1 ? -1 : 1;
|
||||
while (rest > 0) {
|
||||
c.add(Calendar.DATE, add);
|
||||
boolean work = true;
|
||||
Holiday holiday = HolidayUtil.getHoliday(c.get(Calendar.YEAR), c.get(Calendar.MONTH)+1, c.get(Calendar.DAY_OF_MONTH));
|
||||
if(null==holiday){
|
||||
int week = c.get(Calendar.DAY_OF_WEEK);
|
||||
if(1==week||7==week){
|
||||
work = false;
|
||||
}
|
||||
}else{
|
||||
work = holiday.isWork();
|
||||
}
|
||||
if(work){
|
||||
rest--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Solar(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,16 +39,17 @@ public class DaYun {
|
||||
this.yun = yun;
|
||||
this.lunar = yun.getLunar();
|
||||
this.index = index;
|
||||
int birthYear = lunar.getSolar().getYear();
|
||||
int year = yun.getStartSolar().getYear();
|
||||
if (index < 1) {
|
||||
this.startYear = lunar.getSolar().getYear();
|
||||
this.startYear = birthYear;
|
||||
this.startAge = 1;
|
||||
this.endYear = year - 1;
|
||||
this.endAge = yun.getStartYear();
|
||||
this.endAge = year - birthYear;
|
||||
} else {
|
||||
int add = (index - 1) * 10;
|
||||
this.startYear = year + add;
|
||||
this.startAge = yun.getStartYear() + add + 1;
|
||||
this.startAge = this.startYear - birthYear + 1;
|
||||
this.endYear = this.startYear + 9;
|
||||
this.endAge = this.startAge + 9;
|
||||
}
|
||||
@@ -99,6 +100,22 @@ public class DaYun {
|
||||
return LunarUtil.JIA_ZI[offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getXun(){
|
||||
return LunarUtil.getXun(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getXunKong(){
|
||||
return LunarUtil.getXunKong(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流年
|
||||
*
|
||||
|
||||
@@ -61,6 +61,26 @@ public class LiuNian {
|
||||
return LunarUtil.JIA_ZI[offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getXun(){
|
||||
return LunarUtil.getXun(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getXunKong(){
|
||||
return LunarUtil.getXunKong(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流月
|
||||
* @return 流月
|
||||
*/
|
||||
public LiuYue[] getLiuYue() {
|
||||
int n = 12;
|
||||
LiuYue[] l = new LiuYue[n];
|
||||
|
||||
@@ -61,4 +61,20 @@ public class LiuYue {
|
||||
String zhi = LunarUtil.ZHI[(index + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12 + 1];
|
||||
return gan + zhi;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getXun(){
|
||||
return LunarUtil.getXun(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getXunKong(){
|
||||
return LunarUtil.getXunKong(getGanZhi());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,20 @@ public class XiaoYun {
|
||||
offset %= size;
|
||||
return LunarUtil.JIA_ZI[offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所在旬
|
||||
* @return 旬
|
||||
*/
|
||||
public String getXun(){
|
||||
return LunarUtil.getXun(getGanZhi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取旬空(空亡)
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public String getXunKong(){
|
||||
return LunarUtil.getXunKong(getGanZhi());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,6 +31,10 @@ public class LunarUtil{
|
||||
public static final int[] LEAP_MONTH_YEAR = {6,14,19,25,33,36,38,41,44,52,55,79,117,136,147,150,155,158,185,193};
|
||||
/** 闰月表 */
|
||||
public static final int[] LUNAR_MONTH = {0x00,0x04,0xad,0x08,0x5a,0x01,0xd5,0x54,0xb4,0x09,0x64,0x05,0x59,0x45,0x95,0x0a,0xa6,0x04,0x55,0x24,0xad,0x08,0x5a,0x62,0xda,0x04,0xb4,0x05,0xb4,0x55,0x52,0x0d,0x94,0x0a,0x4a,0x2a,0x56,0x02,0x6d,0x71,0x6d,0x01,0xda,0x02,0xd2,0x52,0xa9,0x05,0x49,0x0d,0x2a,0x45,0x2b,0x09,0x56,0x01,0xb5,0x20,0x6d,0x01,0x59,0x69,0xd4,0x0a,0xa8,0x05,0xa9,0x56,0xa5,0x04,0x2b,0x09,0x9e,0x38,0xb6,0x08,0xec,0x74,0x6c,0x05,0xd4,0x0a,0xe4,0x6a,0x52,0x05,0x95,0x0a,0x5a,0x42,0x5b,0x04,0xb6,0x04,0xb4,0x22,0x6a,0x05,0x52,0x75,0xc9,0x0a,0x52,0x05,0x35,0x55,0x4d,0x0a,0x5a,0x02,0x5d,0x31,0xb5,0x02,0x6a,0x8a,0x68,0x05,0xa9,0x0a,0x8a,0x6a,0x2a,0x05,0x2d,0x09,0xaa,0x48,0x5a,0x01,0xb5,0x09,0xb0,0x39,0x64,0x05,0x25,0x75,0x95,0x0a,0x96,0x04,0x4d,0x54,0xad,0x04,0xda,0x04,0xd4,0x44,0xb4,0x05,0x54,0x85,0x52,0x0d,0x92,0x0a,0x56,0x6a,0x56,0x02,0x6d,0x02,0x6a,0x41,0xda,0x02,0xb2,0xa1,0xa9,0x05,0x49,0x0d,0x0a,0x6d,0x2a,0x09,0x56,0x01,0xad,0x50,0x6d,0x01,0xd9,0x02,0xd1,0x3a,0xa8,0x05,0x29,0x85,0xa5,0x0c,0x2a,0x09,0x96,0x54,0xb6,0x08,0x6c,0x09,0x64,0x45,0xd4,0x0a,0xa4,0x05,0x51,0x25,0x95,0x0a,0x2a,0x72,0x5b,0x04,0xb6,0x04,0xac,0x52,0x6a,0x05,0xd2,0x0a,0xa2,0x4a,0x4a,0x05,0x55,0x94,0x2d,0x0a,0x5a,0x02,0x75,0x61,0xb5,0x02,0x6a,0x03,0x61,0x45,0xa9,0x0a,0x4a,0x05,0x25,0x25,0x2d,0x09,0x9a,0x68,0xda,0x08,0xb4,0x09,0xa8,0x59,0x54,0x03,0xa5,0x0a,0x91,0x3a,0x96,0x04,0xad,0xb0,0xad,0x04,0xda,0x04,0xf4,0x62,0xb4,0x05,0x54,0x0b,0x44,0x5d,0x52,0x0a,0x95,0x04,0x55,0x22,0x6d,0x02,0x5a,0x71,0xda,0x02,0xaa,0x05,0xb2,0x55,0x49,0x0b,0x4a,0x0a,0x2d,0x39,0x36,0x01,0x6d,0x80,0x6d,0x01,0xd9,0x02,0xe9,0x6a,0xa8,0x05,0x29,0x0b,0x9a,0x4c,0xaa,0x08,0xb6,0x08,0xb4,0x38,0x6c,0x09,0x54,0x75,0xd4,0x0a,0xa4,0x05,0x45,0x55,0x95,0x0a,0x9a,0x04,0x55,0x44,0xb5,0x04,0x6a,0x82,0x6a,0x05,0xd2,0x0a,0x92,0x6a,0x4a,0x05,0x55,0x0a,0x2a,0x4a,0x5a,0x02,0xb5,0x02,0xb2,0x31,0x69,0x03,0x31,0x73,0xa9,0x0a,0x4a,0x05,0x2d,0x55,0x2d,0x09,0x5a,0x01,0xd5,0x48,0xb4,0x09,0x68,0x89,0x54,0x0b,0xa4,0x0a,0xa5,0x6a,0x95,0x04,0xad,0x08,0x6a,0x44,0xda,0x04,0x74,0x05,0xb0,0x25,0x54,0x03};
|
||||
/** 旬 */
|
||||
public static final String[] XUN = {"甲子","甲戌","甲申","甲午","甲辰","甲寅"};
|
||||
/** 旬空 */
|
||||
public static final String[] XUN_KONG = {"戌亥","申酉","午未","辰巳","寅卯","子丑"};
|
||||
/** 天干 */
|
||||
public static final String[] GAN = {"","甲","乙","丙","丁","戊","己","庚","辛","壬","癸"};
|
||||
/** 喜神方位,《喜神方位歌》:甲己在艮乙庚乾,丙辛坤位喜神安. 丁壬只在离宫坐,戊癸原在在巽间。 */
|
||||
@@ -1444,4 +1448,51 @@ public class LunarUtil{
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取干支所在旬下标,0-5
|
||||
* @param ganZhi 干支
|
||||
* @return 旬下标,0-5
|
||||
*/
|
||||
protected static int getXunIndex(String ganZhi){
|
||||
String gan = ganZhi.substring(0,1);
|
||||
String zhi = ganZhi.substring(1);
|
||||
int ganIndex = 0;
|
||||
int zhiIndex = 0;
|
||||
for(int i=0,j=GAN.length;i<j;i++){
|
||||
if(GAN[i].equals(gan)){
|
||||
ganIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(int i=0,j=ZHI.length;i<j;i++){
|
||||
if(ZHI[i].equals(zhi)){
|
||||
zhiIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int diff = ganIndex - zhiIndex;
|
||||
if(diff<0){
|
||||
diff += 12;
|
||||
}
|
||||
return diff/2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取干支所在旬
|
||||
* @param ganZhi 干支
|
||||
* @return 旬
|
||||
*/
|
||||
public static String getXun(String ganZhi){
|
||||
return XUN[getXunIndex(ganZhi)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取干支所在旬对应的旬空(空亡)
|
||||
* @param ganZhi 干支
|
||||
* @return 旬空(空亡)
|
||||
*/
|
||||
public static String getXunKong(String ganZhi){
|
||||
return XUN_KONG[getXunIndex(ganZhi)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ public class SolarUtil{
|
||||
put("10-13",Collections.nCopies(1,"中国少年先锋队诞辰日"));
|
||||
put("10-25",Collections.nCopies(1,"抗美援朝纪念日"));
|
||||
put("11-12",Collections.nCopies(1,"孙中山诞辰纪念日"));
|
||||
put("11-17",Collections.nCopies(1,"国际大学生节"));
|
||||
put("11-28",Collections.nCopies(1,"恩格斯诞辰纪念日"));
|
||||
put("12-1",Collections.nCopies(1,"世界艾滋病日"));
|
||||
put("12-12",Collections.nCopies(1,"西安事变纪念日"));
|
||||
|
||||
@@ -250,6 +250,54 @@ public class BaZiTestNew {
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(years[i] + "年", ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
solar = new Solar(1981, 8, 16, 9, 30, 0);
|
||||
lunar = solar.getLunar();
|
||||
bazi = lunar.getEightChar();
|
||||
yun = bazi.getYun(1);
|
||||
daYun = yun.getDaYun();
|
||||
|
||||
years = new int[]{1981, 1982, 1983};
|
||||
ages = new int[]{1, 2, 3};
|
||||
ganZhi = new String[]{"辛酉","壬戌","癸亥"};
|
||||
l = daYun[0].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
years = new int[]{1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993};
|
||||
ages = new int[]{4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
|
||||
ganZhi = new String[]{"甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午","辛未","壬申","癸酉"};
|
||||
l = daYun[1].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
|
||||
solar = new Solar(1981, 8, 8, 1, 30, 0);
|
||||
lunar = solar.getLunar();
|
||||
bazi = lunar.getEightChar();
|
||||
yun = bazi.getYun(1);
|
||||
daYun = yun.getDaYun();
|
||||
|
||||
l = daYun[0].getLiuNian();
|
||||
Assert.assertEquals(0, l.length);
|
||||
|
||||
years = new int[]{1981,1982, 1983,1984, 1985, 1986, 1987, 1988, 1989, 1990};
|
||||
ages = new int[]{1,2,3,4,5,6,7,8,9,10};
|
||||
ganZhi = new String[]{"辛酉","壬戌","癸亥","甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午"};
|
||||
l = daYun[1].getLiuNian();
|
||||
for (int i = 0, j = l.length; i < j; i++) {
|
||||
LiuNian liuNian = l[i];
|
||||
Assert.assertEquals(years[i], liuNian.getYear());
|
||||
Assert.assertEquals(ages[i], liuNian.getAge());
|
||||
Assert.assertEquals(ganZhi[i], liuNian.getGanZhi());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
33
src/test/java/test/FestivalTest.java
Normal file
33
src/test/java/test/FestivalTest.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package test;
|
||||
|
||||
import com.nlf.calendar.Solar;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 节日测试
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class FestivalTest {
|
||||
@Test
|
||||
public void test() {
|
||||
Solar solar = Solar.fromYmd(2020, 11, 26);
|
||||
Assert.assertEquals("[感恩节]", solar.getFestivals() + "");
|
||||
|
||||
solar = Solar.fromYmd(2020, 6, 21);
|
||||
Assert.assertEquals("[父亲节]", solar.getFestivals() + "");
|
||||
|
||||
solar = Solar.fromYmd(2021, 5, 9);
|
||||
Assert.assertEquals("[母亲节]", solar.getFestivals() + "");
|
||||
|
||||
solar = Solar.fromYmd(1986, 11, 27);
|
||||
Assert.assertEquals("[感恩节]", solar.getFestivals() + "");
|
||||
|
||||
solar = Solar.fromYmd(1985, 6, 16);
|
||||
Assert.assertEquals("[父亲节]", solar.getFestivals() + "");
|
||||
|
||||
solar = Solar.fromYmd(1984, 5, 13);
|
||||
Assert.assertEquals("[母亲节]", solar.getFestivals() + "");
|
||||
}
|
||||
}
|
||||
49
src/test/java/test/HolidayTest.java
Normal file
49
src/test/java/test/HolidayTest.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package test;
|
||||
|
||||
import com.nlf.calendar.util.HolidayUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HolidayTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
Assert.assertEquals("2020-01-01 元旦节 2020-01-01",HolidayUtil.getHoliday("2020-01-01")+"");
|
||||
|
||||
// 将2020-01-01修改为春节
|
||||
HolidayUtil.fix("202001011120200101");
|
||||
Assert.assertEquals("2020-01-01 春节 2020-01-01",HolidayUtil.getHoliday("2020-01-01")+"");
|
||||
|
||||
// 追加2099-01-01为元旦节
|
||||
HolidayUtil.fix("209901010120990101");
|
||||
Assert.assertEquals("2099-01-01 元旦节 2099-01-01",HolidayUtil.getHoliday("2099-01-01")+"");
|
||||
|
||||
// 将2020-01-01修改为春节,并追加2099-01-01为元旦节
|
||||
HolidayUtil.fix("202001011120200101209901010120990101");
|
||||
Assert.assertEquals("2020-01-01 春节 2020-01-01",HolidayUtil.getHoliday("2020-01-01")+"");
|
||||
Assert.assertEquals("2099-01-01 元旦节 2099-01-01",HolidayUtil.getHoliday("2099-01-01")+"");
|
||||
|
||||
// 更改节假日名称
|
||||
String[] names = HolidayUtil.NAMES;
|
||||
names[0] = "元旦";
|
||||
names[1] = "大年初一";
|
||||
|
||||
HolidayUtil.fix(names, null);
|
||||
Assert.assertEquals("2020-01-01 大年初一 2020-01-01",HolidayUtil.getHoliday("2020-01-01")+"");
|
||||
Assert.assertEquals("2099-01-01 元旦 2099-01-01",HolidayUtil.getHoliday("2099-01-01")+"");
|
||||
|
||||
// 追加节假日名称和数据
|
||||
names = new String[12];
|
||||
for(int i=0,j=HolidayUtil.NAMES.length;i<j;i++){
|
||||
names[i] = HolidayUtil.NAMES[i];
|
||||
}
|
||||
names[9] = "我的生日";
|
||||
names[10] = "结婚纪念日";
|
||||
names[11] = "她的生日";
|
||||
|
||||
HolidayUtil.fix(names, "20210529912021052920211111:12021111120211201;120211201");
|
||||
Assert.assertEquals("2021-05-29 我的生日 2021-05-29",HolidayUtil.getHoliday("2021-05-29")+"");
|
||||
Assert.assertEquals("2021-11-11 结婚纪念日 2021-11-11",HolidayUtil.getHoliday("2021-11-11")+"");
|
||||
Assert.assertEquals("2021-12-01 她的生日 2021-12-01",HolidayUtil.getHoliday("2021-12-01")+"");
|
||||
}
|
||||
}
|
||||
@@ -154,5 +154,23 @@ public class JieQiTest {
|
||||
Assert.assertEquals("小寒", lunar.getNextJie().getName());
|
||||
Assert.assertEquals("大寒", lunar.getNextQi().getName());
|
||||
Assert.assertEquals("小寒", lunar.getNextJieQi().getName());
|
||||
|
||||
|
||||
solar = Solar.fromYmd(2012,12,25);
|
||||
lunar = solar.getLunar();
|
||||
Assert.assertEquals("", lunar.getJie());
|
||||
Assert.assertEquals("", lunar.getQi());
|
||||
Assert.assertEquals("", lunar.getJieQi());
|
||||
Assert.assertNull(lunar.getCurrentJie());
|
||||
Assert.assertNull(lunar.getCurrentQi());
|
||||
Assert.assertNull(lunar.getCurrentJieQi());
|
||||
|
||||
Assert.assertEquals("小寒", lunar.getNextJie().getName());
|
||||
Assert.assertEquals("大寒", lunar.getNextQi().getName());
|
||||
Assert.assertEquals("小寒", lunar.getNextJieQi().getName());
|
||||
|
||||
Assert.assertEquals("大雪", lunar.getPrevJie().getName());
|
||||
Assert.assertEquals("冬至", lunar.getPrevQi().getName());
|
||||
Assert.assertEquals("冬至", lunar.getPrevJieQi().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,27 @@ public class SolarTest {
|
||||
Assert.assertEquals("二〇一九年三月廿七 己亥(猪)年 戊辰(龙)月 戊戌(狗)日 子(鼠)时 纳音[平地木 大林木 平地木 桑柘木] 星期三 (七殿泰山王诞) 西方白虎 星宿[参水猿](吉) 彭祖百忌[戊不受田田主不祥 戌不吃犬作怪上床] 喜神方位[巽](东南) 阳贵神方位[艮](东北) 阴贵神方位[坤](西南) 福神方位[坎](正北) 财神方位[坎](正北) 冲[(壬辰)龙] 煞[北]",date.getLunar().toFullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNext(){
|
||||
Solar date = new Solar(2020,1,23);
|
||||
Assert.assertEquals("2020-01-24",date.next(1).toString());
|
||||
// 仅工作日,跨越春节假期
|
||||
Assert.assertEquals("2020-02-03",date.next(1,true).toString());
|
||||
|
||||
date = new Solar(2020,2,3);
|
||||
Assert.assertEquals("2020-01-31",date.next(-3).toString());
|
||||
// 仅工作日,跨越春节假期
|
||||
Assert.assertEquals("2020-01-21",date.next(-3,true).toString());
|
||||
|
||||
date = new Solar(2020,2,9);
|
||||
Assert.assertEquals("2020-02-15",date.next(6).toString());
|
||||
// 仅工作日,跨越周末
|
||||
Assert.assertEquals("2020-02-17",date.next(6,true).toString());
|
||||
|
||||
date = new Solar(2020,1,17);
|
||||
Assert.assertEquals("2020-01-18",date.next(1).toString());
|
||||
// 仅工作日,周日调休按上班算
|
||||
Assert.assertEquals("2020-01-19",date.next(1,true).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
182
src/test/java/test/XunTest.java
Normal file
182
src/test/java/test/XunTest.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package test;
|
||||
|
||||
import com.nlf.calendar.EightChar;
|
||||
import com.nlf.calendar.Lunar;
|
||||
import com.nlf.calendar.Solar;
|
||||
import com.nlf.calendar.util.LunarUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 旬测试
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class XunTest {
|
||||
|
||||
@Test
|
||||
public void testXun(){
|
||||
Map<String,String> xun = new HashMap<String, String>();
|
||||
xun.put("甲子","甲子");
|
||||
xun.put("乙丑","甲子");
|
||||
xun.put("丙寅","甲子");
|
||||
xun.put("丁卯","甲子");
|
||||
xun.put("戊辰","甲子");
|
||||
xun.put("己巳","甲子");
|
||||
xun.put("庚午","甲子");
|
||||
xun.put("辛未","甲子");
|
||||
xun.put("壬申","甲子");
|
||||
xun.put("癸酉","甲子");
|
||||
xun.put("甲戌","甲戌");
|
||||
xun.put("乙亥","甲戌");
|
||||
xun.put("丙子","甲戌");
|
||||
xun.put("丁丑","甲戌");
|
||||
xun.put("戊寅","甲戌");
|
||||
xun.put("己卯","甲戌");
|
||||
xun.put("庚辰","甲戌");
|
||||
xun.put("辛巳","甲戌");
|
||||
xun.put("壬午","甲戌");
|
||||
xun.put("癸未","甲戌");
|
||||
xun.put("甲申","甲申");
|
||||
xun.put("乙酉","甲申");
|
||||
xun.put("丙戌","甲申");
|
||||
xun.put("丁亥","甲申");
|
||||
xun.put("戊子","甲申");
|
||||
xun.put("己丑","甲申");
|
||||
xun.put("庚寅","甲申");
|
||||
xun.put("辛卯","甲申");
|
||||
xun.put("壬辰","甲申");
|
||||
xun.put("癸巳","甲申");
|
||||
xun.put("甲午","甲午");
|
||||
xun.put("乙未","甲午");
|
||||
xun.put("丙申","甲午");
|
||||
xun.put("丁酉","甲午");
|
||||
xun.put("戊戌","甲午");
|
||||
xun.put("己亥","甲午");
|
||||
xun.put("庚子","甲午");
|
||||
xun.put("辛丑","甲午");
|
||||
xun.put("壬寅","甲午");
|
||||
xun.put("癸卯","甲午");
|
||||
xun.put("甲辰","甲辰");
|
||||
xun.put("乙巳","甲辰");
|
||||
xun.put("丙午","甲辰");
|
||||
xun.put("丁未","甲辰");
|
||||
xun.put("戊申","甲辰");
|
||||
xun.put("己酉","甲辰");
|
||||
xun.put("庚戌","甲辰");
|
||||
xun.put("辛亥","甲辰");
|
||||
xun.put("壬子","甲辰");
|
||||
xun.put("癸丑","甲辰");
|
||||
xun.put("甲寅","甲寅");
|
||||
xun.put("乙卯","甲寅");
|
||||
xun.put("丙辰","甲寅");
|
||||
xun.put("丁巳","甲寅");
|
||||
xun.put("戊午","甲寅");
|
||||
xun.put("己未","甲寅");
|
||||
xun.put("庚申","甲寅");
|
||||
xun.put("辛酉","甲寅");
|
||||
xun.put("壬戌","甲寅");
|
||||
xun.put("癸亥","甲寅");
|
||||
|
||||
for(Map.Entry<String,String> entry:xun.entrySet()){
|
||||
Assert.assertEquals(entry.getValue(), LunarUtil.getXun(entry.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXunKong(){
|
||||
Map<String,String> kong = new HashMap<String, String>();
|
||||
kong.put("甲子","戌亥");
|
||||
kong.put("乙丑","戌亥");
|
||||
kong.put("丙寅","戌亥");
|
||||
kong.put("丁卯","戌亥");
|
||||
kong.put("戊辰","戌亥");
|
||||
kong.put("己巳","戌亥");
|
||||
kong.put("庚午","戌亥");
|
||||
kong.put("辛未","戌亥");
|
||||
kong.put("壬申","戌亥");
|
||||
kong.put("癸酉","戌亥");
|
||||
kong.put("甲戌","申酉");
|
||||
kong.put("乙亥","申酉");
|
||||
kong.put("丙子","申酉");
|
||||
kong.put("丁丑","申酉");
|
||||
kong.put("戊寅","申酉");
|
||||
kong.put("己卯","申酉");
|
||||
kong.put("庚辰","申酉");
|
||||
kong.put("辛巳","申酉");
|
||||
kong.put("壬午","申酉");
|
||||
kong.put("癸未","申酉");
|
||||
kong.put("甲申","午未");
|
||||
kong.put("乙酉","午未");
|
||||
kong.put("丙戌","午未");
|
||||
kong.put("丁亥","午未");
|
||||
kong.put("戊子","午未");
|
||||
kong.put("己丑","午未");
|
||||
kong.put("庚寅","午未");
|
||||
kong.put("辛卯","午未");
|
||||
kong.put("壬辰","午未");
|
||||
kong.put("癸巳","午未");
|
||||
kong.put("甲午","辰巳");
|
||||
kong.put("乙未","辰巳");
|
||||
kong.put("丙申","辰巳");
|
||||
kong.put("丁酉","辰巳");
|
||||
kong.put("戊戌","辰巳");
|
||||
kong.put("己亥","辰巳");
|
||||
kong.put("庚子","辰巳");
|
||||
kong.put("辛丑","辰巳");
|
||||
kong.put("壬寅","辰巳");
|
||||
kong.put("癸卯","辰巳");
|
||||
kong.put("甲辰","寅卯");
|
||||
kong.put("乙巳","寅卯");
|
||||
kong.put("丙午","寅卯");
|
||||
kong.put("丁未","寅卯");
|
||||
kong.put("戊申","寅卯");
|
||||
kong.put("己酉","寅卯");
|
||||
kong.put("庚戌","寅卯");
|
||||
kong.put("辛亥","寅卯");
|
||||
kong.put("壬子","寅卯");
|
||||
kong.put("癸丑","寅卯");
|
||||
kong.put("甲寅","子丑");
|
||||
kong.put("乙卯","子丑");
|
||||
kong.put("丙辰","子丑");
|
||||
kong.put("丁巳","子丑");
|
||||
kong.put("戊午","子丑");
|
||||
kong.put("己未","子丑");
|
||||
kong.put("庚申","子丑");
|
||||
kong.put("辛酉","子丑");
|
||||
kong.put("壬戌","子丑");
|
||||
kong.put("癸亥","子丑");
|
||||
|
||||
for(Map.Entry<String,String> entry:kong.entrySet()){
|
||||
Assert.assertEquals(entry.getValue(), LunarUtil.getXunKong(entry.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXun1(){
|
||||
Solar solar = new Solar(2020,11,19,0,0,0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("甲午",lunar.getYearXun());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXunKong1(){
|
||||
Solar solar = new Solar(2020,11,19,0,0,0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("辰巳",lunar.getYearXunKong());
|
||||
Assert.assertEquals("午未",lunar.getMonthXunKong());
|
||||
Assert.assertEquals("戌亥",lunar.getDayXunKong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaZiDayXunKong(){
|
||||
Solar solar = new Solar(1990,12,23,8,37,0);
|
||||
Lunar lunar = solar.getLunar();
|
||||
EightChar eightChar = lunar.getEightChar();
|
||||
Assert.assertEquals("子丑",eightChar.getDayXunKong());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user