Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9ec0fc4b9 | ||
|
|
bab052909b | ||
|
|
868aaac231 |
32
README.md
32
README.md
@@ -1,6 +1,6 @@
|
||||
# lunar [](https://github.com/6tail/lunar-java/blob/master/LICENSE)
|
||||
|
||||
lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)工具,支持星座、儒略日、干支、生肖、节气、节日、彭祖百忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道日及吉凶、法定节假日及调休等。
|
||||
lunar是一款无第三方依赖的公历(阳历)、农历(阴历、老黄历)、道历、佛历工具,支持星座、儒略日、干支、生肖、节气、节日、彭祖百忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道日及吉凶、法定节假日及调休等。
|
||||
|
||||
> 支持java 1.5及以上版本。
|
||||
|
||||
@@ -16,7 +16,7 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
<dependency>
|
||||
<groupId>cn.6tail</groupId>
|
||||
<artifactId>lunar</artifactId>
|
||||
<version>1.2.11</version>
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -54,3 +54,31 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
|
||||
## 文档
|
||||
|
||||
请移步至 [http://6tail.cn/calendar/api.html](http://6tail.cn/calendar/api.html "http://6tail.cn/calendar/api.html")
|
||||
|
||||
## 更新日志
|
||||
|
||||
v1.2.14 佛历新增27宿;修复宜忌重复的问题;修复获取气时缺冬至的问题。
|
||||
|
||||
v1.2.13 新增道历Tao。
|
||||
|
||||
v1.2.12 修复星宿方位错误。
|
||||
|
||||
v1.2.11 修正胎神数据;增加福神流派。
|
||||
|
||||
v1.2.9 新增2022年法定假日。
|
||||
|
||||
v1.2.8 新增佛历Foto;更改Lunar中的getOtherFestivals方法为传统节日。
|
||||
|
||||
v1.2.7 修复儒略日转阳历秒数为60的错误。
|
||||
|
||||
v1.2.6 新增治水、分饼、耕田、得金、日禄;新增时辰LunarTime;新增获取当天的所有时辰。
|
||||
|
||||
v1.2.5 修复公元0至4年转阴历错误的问题。
|
||||
|
||||
v1.2.4 修复闰冬月、闰腊月的问题;修复日历不准的问题;修复物候错误;大运、小运、流年支持自定义轮数。
|
||||
|
||||
v1.2.3 修复除夕错误;代码优化。
|
||||
|
||||
v1.2.2 修正2016年国庆节数据;删除5月23日世界读书日;修复v1.2.0和v1.2.1的重大bug。
|
||||
|
||||
v1.2.0 支持0001到9999年。
|
||||
|
||||
@@ -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.11</version>
|
||||
<version>1.2.13</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.11</version>
|
||||
<version>1.2.14</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>
|
||||
|
||||
@@ -28,12 +28,12 @@ public class Foto {
|
||||
return new Foto(lunar);
|
||||
}
|
||||
|
||||
public static Foto fromYmdHms(int lunarYear, int lunarMonth, int lunarDay, int hour, int minute, int second) {
|
||||
return Foto.fromLunar(Lunar.fromYmdHms(lunarYear + DEAD_YEAR - 1, lunarMonth, lunarDay, hour, minute, second));
|
||||
public static Foto fromYmdHms(int year, int month, int day, int hour, int minute, int second) {
|
||||
return Foto.fromLunar(Lunar.fromYmdHms(year + DEAD_YEAR - 1, month, day, hour, minute, second));
|
||||
}
|
||||
|
||||
public static Foto fromYmd(int lunarYear, int lunarMonth, int lunarDay) {
|
||||
return fromYmdHms(lunarYear, lunarMonth, lunarDay, 0, 0, 0);
|
||||
public static Foto fromYmd(int year, int month, int day) {
|
||||
return fromYmdHms(year, month, day, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Lunar getLunar() {
|
||||
@@ -83,11 +83,21 @@ public class Foto {
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否月斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isMonthZhai() {
|
||||
int m = getMonth();
|
||||
return 1 == m || 5 == m || 9 == m;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否杨公忌
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayYangGong() {
|
||||
for (FotoFestival f : getFestivals()) {
|
||||
if ("杨公忌".equals(f.getName())) {
|
||||
@@ -97,11 +107,21 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否朔望斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiShuoWang() {
|
||||
int d = getDay();
|
||||
return 1 == d || 15 == d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否六斋日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiSix() {
|
||||
int d = getDay();
|
||||
if (8 == d || 14 == d || 15 == d || 23 == d || 29 == d || 30 == d) {
|
||||
@@ -113,11 +133,21 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否十斋日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiTen() {
|
||||
int d = getDay();
|
||||
return 1 == d || 8 == d || 14 == d || 15 == d || 18 == d || 23 == d || 24 == d || 28 == d || 29 == d || 30 == d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否观音斋
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayZhaiGuanYin() {
|
||||
String k = getMonth() + "-" + getDay();
|
||||
for (String d : FotoUtil.DAY_ZHAI_GUAN_YIN) {
|
||||
@@ -128,6 +158,69 @@ public class Foto {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取星宿
|
||||
*
|
||||
* @return 星宿
|
||||
*/
|
||||
public String getXiu() {
|
||||
return FotoUtil.getXiu(getMonth(), getDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宿吉凶
|
||||
*
|
||||
* @return 吉/凶
|
||||
*/
|
||||
public String getXiuLuck() {
|
||||
return LunarUtil.XIU_LUCK.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宿歌诀
|
||||
*
|
||||
* @return 宿歌诀
|
||||
*/
|
||||
public String getXiuSong() {
|
||||
return LunarUtil.XIU_SONG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取政
|
||||
*
|
||||
* @return 政
|
||||
*/
|
||||
public String getZheng() {
|
||||
return LunarUtil.ZHENG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动物
|
||||
*
|
||||
* @return 动物
|
||||
*/
|
||||
public String getAnimal() {
|
||||
return LunarUtil.ANIMAL.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宫
|
||||
*
|
||||
* @return 宫
|
||||
*/
|
||||
public String getGong() {
|
||||
return LunarUtil.GONG.get(getXiu());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取兽
|
||||
*
|
||||
* @return 兽
|
||||
*/
|
||||
public String getShou() {
|
||||
return LunarUtil.SHOU.get(getGong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getYearInChinese() + "年" + getMonthInChinese() + "月" + getDayInChinese();
|
||||
|
||||
@@ -64,6 +64,10 @@ public class FotoFestival {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toFullString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(name);
|
||||
if (null != result && result.length() > 0) {
|
||||
|
||||
@@ -842,8 +842,8 @@ public class Lunar {
|
||||
*/
|
||||
public String getJie() {
|
||||
String jie = "";
|
||||
for(int i=1,j=JIE_QI.length;i<j;i+=2){
|
||||
String key = JIE_QI[i];
|
||||
for(int i=0,j=JIE_QI_IN_USE.length;i<j;i+=2){
|
||||
String key = JIE_QI_IN_USE[i];
|
||||
Solar d = jieQi.get(key);
|
||||
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
|
||||
jie = key;
|
||||
@@ -860,8 +860,8 @@ public class Lunar {
|
||||
*/
|
||||
public String getQi() {
|
||||
String qi = "";
|
||||
for(int i=0,j=JIE_QI.length;i<j;i+=2){
|
||||
String key = JIE_QI[i];
|
||||
for(int i=1,j=JIE_QI_IN_USE.length;i<j;i+=2){
|
||||
String key = JIE_QI_IN_USE[i];
|
||||
Solar d = jieQi.get(key);
|
||||
if (d.getYear() == solar.getYear() && d.getMonth() == solar.getMonth() && d.getDay() == solar.getDay()) {
|
||||
qi = key;
|
||||
@@ -2690,4 +2690,13 @@ public class Lunar {
|
||||
return Foto.fromLunar(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取道历
|
||||
*
|
||||
* @return 佛历
|
||||
*/
|
||||
public Tao getTao() {
|
||||
return Tao.fromLunar(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
161
src/main/java/com/nlf/calendar/Tao.java
Normal file
161
src/main/java/com/nlf/calendar/Tao.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.nlf.calendar;
|
||||
|
||||
import com.nlf.calendar.util.LunarUtil;
|
||||
import com.nlf.calendar.util.TaoUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 道历
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class Tao {
|
||||
|
||||
public static final int BIRTH_YEAR = -2697;
|
||||
|
||||
/**
|
||||
* 阴历
|
||||
*/
|
||||
private Lunar lunar;
|
||||
|
||||
public Tao(Lunar lunar) {
|
||||
this.lunar = lunar;
|
||||
}
|
||||
|
||||
public static Tao fromLunar(Lunar lunar) {
|
||||
return new Tao(lunar);
|
||||
}
|
||||
|
||||
public static Tao fromYmdHms(int year, int month, int day, int hour, int minute, int second) {
|
||||
return Tao.fromLunar(Lunar.fromYmdHms(year + BIRTH_YEAR, month, day, hour, minute, second));
|
||||
}
|
||||
|
||||
public static Tao fromYmd(int year, int month, int day) {
|
||||
return fromYmdHms(year, month, day, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Lunar getLunar() {
|
||||
return lunar;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return lunar.getYear() - BIRTH_YEAR;
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
return lunar.getMonth();
|
||||
}
|
||||
|
||||
public int getDay() {
|
||||
return lunar.getDay();
|
||||
}
|
||||
|
||||
public String getYearInChinese() {
|
||||
String y = getYear() + "";
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0, j = y.length(); i < j; i++) {
|
||||
s.append(LunarUtil.NUMBER[y.charAt(i) - '0']);
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public String getMonthInChinese() {
|
||||
return lunar.getMonthInChinese();
|
||||
}
|
||||
|
||||
public String getDayInChinese() {
|
||||
return lunar.getDayInChinese();
|
||||
}
|
||||
|
||||
public List<TaoFestival> getFestivals() {
|
||||
List<TaoFestival> l = new ArrayList<TaoFestival>();
|
||||
List<TaoFestival> fs = TaoUtil.FESTIVAL.get(getMonth() + "-" + getDay());
|
||||
if (null != fs) {
|
||||
l.addAll(fs);
|
||||
}
|
||||
String jq = lunar.getJieQi();
|
||||
if ("冬至".equals(jq)) {
|
||||
l.add(new TaoFestival("元始天尊圣诞"));
|
||||
} else if ("夏至".equals(jq)) {
|
||||
l.add(new TaoFestival("灵宝天尊圣诞"));
|
||||
}
|
||||
// 八节日
|
||||
String f = TaoUtil.BA_JIE.get(jq);
|
||||
if (null != f) {
|
||||
l.add(new TaoFestival(f));
|
||||
}
|
||||
// 八会日
|
||||
f = TaoUtil.BA_HUI.get(lunar.getDayInGanZhi());
|
||||
if (null != f) {
|
||||
l.add(new TaoFestival(f));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
private boolean isDayIn(String[] days) {
|
||||
String md = getMonth() + "-" + getDay();
|
||||
for (String d : days) {
|
||||
if (md.equals(d)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否三会日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDaySanHui() {
|
||||
return isDayIn(TaoUtil.SAN_HUI);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否三元日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDaySanYuan() {
|
||||
return isDayIn(TaoUtil.SAN_YUAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否八节日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayBaJie() {
|
||||
return TaoUtil.BA_JIE.containsKey(lunar.getJieQi());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否五腊日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayWuLa() {
|
||||
return isDayIn(TaoUtil.WU_LA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否八会日
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean isDayBaHui() {
|
||||
return TaoUtil.BA_HUI.containsKey(lunar.getDayInGanZhi());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s年%s月%s", getYearInChinese(), getMonthInChinese(), getDayInChinese());
|
||||
}
|
||||
|
||||
public String toFullString() {
|
||||
return String.format("道歷%s年,天運%s年,%s月,%s日。%s月%s日,%s時。", getYearInChinese(), lunar.getYearInGanZhi(), lunar.getMonthInGanZhi(), lunar.getDayInGanZhi(), getMonthInChinese(), getDayInChinese(), lunar.getTimeZhi());
|
||||
}
|
||||
|
||||
}
|
||||
52
src/main/java/com/nlf/calendar/TaoFestival.java
Normal file
52
src/main/java/com/nlf/calendar/TaoFestival.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.nlf.calendar;
|
||||
|
||||
/**
|
||||
* 道历节日
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class TaoFestival {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public TaoFestival(String name, String remark) {
|
||||
this.name = name;
|
||||
this.remark = null == remark ? "" : remark;
|
||||
}
|
||||
|
||||
public TaoFestival(String name) {
|
||||
this(name, null);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toFullString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append(name);
|
||||
if (null != remark && remark.length() > 0) {
|
||||
s.append("[");
|
||||
s.append(remark);
|
||||
s.append("]");
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
}
|
||||
@@ -261,4 +261,25 @@ public class FotoUtil {
|
||||
put("12-30", Collections.nCopies(1, new FotoFestival("诸神下降,察访善恶", "犯者男女俱亡")));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 27星宿,佛教从印度传入中国,印度把28星宿改为27星宿,把牛宿(牛金牛)纳入了女宿(女土蝠)。
|
||||
*/
|
||||
public static final String[] XIU_27 = {"角", "亢", "氐", "房", "心", "尾", "箕", "斗", "女", "虚", "危", "室", "壁", "奎", "娄", "胃", "昴", "毕", "觜", "参", "井", "鬼", "柳", "星", "张", "翼", "轸"};
|
||||
|
||||
/**
|
||||
* 每月初一的27星宿偏移
|
||||
*/
|
||||
private static final int[] XIU_OFFSET = {11, 13, 15, 17, 19, 21, 24, 0, 2, 4, 7, 9};
|
||||
|
||||
/**
|
||||
* 获取27星宿
|
||||
*
|
||||
* @param month 佛历月
|
||||
* @param day 佛历日
|
||||
* @return 星宿
|
||||
*/
|
||||
public static String getXiu(int month, int day) {
|
||||
return XIU_27[(XIU_OFFSET[Math.abs(month)-1] + day - 1) % XIU_27.length];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
172
src/main/java/com/nlf/calendar/util/TaoUtil.java
Normal file
172
src/main/java/com/nlf/calendar/util/TaoUtil.java
Normal file
@@ -0,0 +1,172 @@
|
||||
package com.nlf.calendar.util;
|
||||
|
||||
import com.nlf.calendar.TaoFestival;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 道历工具
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class TaoUtil {
|
||||
/**
|
||||
* 日期对应的节日
|
||||
*/
|
||||
public static final Map<String, List<TaoFestival>> FESTIVAL = new HashMap<String, List<TaoFestival>>() {
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
{
|
||||
put("1-1", Collections.nCopies(1, new TaoFestival("天腊之辰", "天腊,此日五帝会于束方九炁青天")));
|
||||
put("1-3", Arrays.asList(new TaoFestival("郝真人圣诞"), new TaoFestival("孙真人圣诞")));
|
||||
put("1-5", Collections.nCopies(1, new TaoFestival("孙祖清静元君诞")));
|
||||
put("1-7", Collections.nCopies(1, new TaoFestival("举迁赏会", "此日上元赐福,天官同地水二官考校罪福")));
|
||||
put("1-9", Collections.nCopies(1, new TaoFestival("玉皇上帝圣诞")));
|
||||
put("1-13", Collections.nCopies(1, new TaoFestival("关圣帝君飞升")));
|
||||
put("1-15", Arrays.asList(new TaoFestival("上元天官圣诞"), new TaoFestival("老祖天师圣诞")));
|
||||
put("1-19", Collections.nCopies(1, new TaoFestival("长春邱真人(邱处机)圣诞")));
|
||||
put("1-28", Collections.nCopies(1, new TaoFestival("许真君(许逊天师)圣诞")));
|
||||
put("2-1", Arrays.asList(new TaoFestival("勾陈天皇大帝圣诞"), new TaoFestival("长春刘真人(刘渊然)圣诞")));
|
||||
put("2-2", Arrays.asList(new TaoFestival("土地正神诞"), new TaoFestival("姜太公圣诞")));
|
||||
put("2-3", Collections.nCopies(1, new TaoFestival("文昌梓潼帝君圣诞")));
|
||||
put("2-6", Collections.nCopies(1, new TaoFestival("东华帝君圣诞")));
|
||||
put("2-13", Collections.nCopies(1, new TaoFestival("度人无量葛真君圣诞")));
|
||||
put("2-15", Collections.nCopies(1, new TaoFestival("太清道德天尊(太上老君)圣诞")));
|
||||
put("2-19", Collections.nCopies(1, new TaoFestival("慈航真人圣诞")));
|
||||
put("3-1", Collections.nCopies(1, new TaoFestival("谭祖(谭处端)长真真人圣诞")));
|
||||
put("3-3", Collections.nCopies(1, new TaoFestival("玄天上帝圣诞")));
|
||||
put("3-6", Collections.nCopies(1, new TaoFestival("眼光娘娘圣诞")));
|
||||
put("3-15", Arrays.asList(new TaoFestival("天师张大真人圣诞"), new TaoFestival("财神赵公元帅圣诞")));
|
||||
put("3-16", Arrays.asList(new TaoFestival("三茅真君得道之辰"), new TaoFestival("中岳大帝圣诞")));
|
||||
put("3-18", Arrays.asList(new TaoFestival("王祖(王处一)玉阳真人圣诞"), new TaoFestival("后土娘娘圣诞")));
|
||||
put("3-19", Collections.nCopies(1, new TaoFestival("太阳星君圣诞")));
|
||||
put("3-20", Collections.nCopies(1, new TaoFestival("子孙娘娘圣诞")));
|
||||
put("3-23", Collections.nCopies(1, new TaoFestival("天后妈祖圣诞")));
|
||||
put("3-26", Collections.nCopies(1, new TaoFestival("鬼谷先师诞")));
|
||||
put("3-28", Collections.nCopies(1, new TaoFestival("东岳大帝圣诞")));
|
||||
put("4-1", Collections.nCopies(1, new TaoFestival("长生谭真君成道之辰")));
|
||||
put("4-10", Collections.nCopies(1, new TaoFestival("何仙姑圣诞")));
|
||||
put("4-14", Collections.nCopies(1, new TaoFestival("吕祖纯阳祖师圣诞")));
|
||||
put("4-15", Collections.nCopies(1, new TaoFestival("钟离祖师圣诞")));
|
||||
put("4-18", Arrays.asList(new TaoFestival("北极紫微大帝圣诞"), new TaoFestival("泰山圣母碧霞元君诞"), new TaoFestival("华佗神医先师诞")));
|
||||
put("4-20", Collections.nCopies(1, new TaoFestival("眼光圣母娘娘诞")));
|
||||
put("4-28", Collections.nCopies(1, new TaoFestival("神农先帝诞")));
|
||||
put("5-1", Collections.nCopies(1, new TaoFestival("南极长生大帝圣诞")));
|
||||
put("5-5", Arrays.asList(new TaoFestival("地腊之辰", "地腊,此日五帝会於南方三炁丹天"), new TaoFestival("南方雷祖圣诞"), new TaoFestival("地祗温元帅圣诞"), new TaoFestival("雷霆邓天君圣诞")));
|
||||
put("5-11", Collections.nCopies(1, new TaoFestival("城隍爷圣诞")));
|
||||
put("5-13", Arrays.asList(new TaoFestival("关圣帝君降神"), new TaoFestival("关平太子圣诞")));
|
||||
put("5-18", Collections.nCopies(1, new TaoFestival("张天师圣诞")));
|
||||
put("5-20", Collections.nCopies(1, new TaoFestival("马祖丹阳真人圣诞")));
|
||||
put("5-29", Collections.nCopies(1, new TaoFestival("紫青白祖师圣诞")));
|
||||
put("6-1", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-2", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-3", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-4", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-5", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-6", Collections.nCopies(1, new TaoFestival("南斗星君下降")));
|
||||
put("6-10", Collections.nCopies(1, new TaoFestival("刘海蟾祖师圣诞")));
|
||||
put("6-15", Collections.nCopies(1, new TaoFestival("灵官王天君圣诞")));
|
||||
put("6-19", Collections.nCopies(1, new TaoFestival("慈航(观音)成道日")));
|
||||
put("6-23", Collections.nCopies(1, new TaoFestival("火神圣诞")));
|
||||
put("6-24", Arrays.asList(new TaoFestival("南极大帝中方雷祖圣诞"), new TaoFestival("关圣帝君圣诞")));
|
||||
put("6-26", Collections.nCopies(1, new TaoFestival("二郎真君圣诞")));
|
||||
put("7-7", Arrays.asList(new TaoFestival("道德腊之辰", "道德腊,此日五帝会于西方七炁素天"), new TaoFestival("庆生中会", "此日中元赦罪,地官同天水二官考校罪福")));
|
||||
put("7-12", Collections.nCopies(1, new TaoFestival("西方雷祖圣诞")));
|
||||
put("7-15", Collections.nCopies(1, new TaoFestival("中元地官大帝圣诞")));
|
||||
put("7-18", Collections.nCopies(1, new TaoFestival("王母娘娘圣诞")));
|
||||
put("7-20", Collections.nCopies(1, new TaoFestival("刘祖(刘处玄)长生真人圣诞")));
|
||||
put("7-22", Collections.nCopies(1, new TaoFestival("财帛星君文财神增福相公李诡祖圣诞")));
|
||||
put("7-26", Collections.nCopies(1, new TaoFestival("张三丰祖师圣诞")));
|
||||
put("8-1", Collections.nCopies(1, new TaoFestival("许真君飞升日")));
|
||||
put("8-3", Collections.nCopies(1, new TaoFestival("九天司命灶君诞")));
|
||||
put("8-5", Collections.nCopies(1, new TaoFestival("北方雷祖圣诞")));
|
||||
put("8-10", Collections.nCopies(1, new TaoFestival("北岳大帝诞辰")));
|
||||
put("8-15", Collections.nCopies(1, new TaoFestival("太阴星君诞")));
|
||||
put("9-1", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-2", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-3", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-4", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-5", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-6", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-7", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-8", Collections.nCopies(1, new TaoFestival("北斗九皇降世之辰")));
|
||||
put("9-9", Arrays.asList(new TaoFestival("北斗九皇降世之辰"), new TaoFestival("斗姥元君圣诞"), new TaoFestival("重阳帝君圣诞"), new TaoFestival("玄天上帝飞升"), new TaoFestival("酆都大帝圣诞")));
|
||||
put("9-22", Collections.nCopies(1, new TaoFestival("增福财神诞")));
|
||||
put("9-23", Collections.nCopies(1, new TaoFestival("萨翁真君圣诞")));
|
||||
put("9-28", Collections.nCopies(1, new TaoFestival("五显灵官马元帅圣诞")));
|
||||
put("10-1", Arrays.asList(new TaoFestival("民岁腊之辰", "民岁腊,此日五帝会於北方五炁黑天"), new TaoFestival("东皇大帝圣诞")));
|
||||
put("10-3", Collections.nCopies(1, new TaoFestival("三茅应化真君圣诞")));
|
||||
put("10-6", Collections.nCopies(1, new TaoFestival("天曹诸司五岳五帝圣诞")));
|
||||
put("10-15", Arrays.asList(new TaoFestival("下元水官大帝圣诞"), new TaoFestival("建生大会", "此日下元解厄,水官同天地二官考校罪福")));
|
||||
put("10-18", Collections.nCopies(1, new TaoFestival("地母娘娘圣诞")));
|
||||
put("10-19", Collections.nCopies(1, new TaoFestival("长春邱真君飞升")));
|
||||
put("10-20", Collections.nCopies(1, new TaoFestival("虚靖天师(即三十代天师弘悟张真人)诞")));
|
||||
put("11-6", Collections.nCopies(1, new TaoFestival("西岳大帝圣诞")));
|
||||
put("11-9", Collections.nCopies(1, new TaoFestival("湘子韩祖圣诞")));
|
||||
put("11-11", Collections.nCopies(1, new TaoFestival("太乙救苦天尊圣诞")));
|
||||
put("11-26", Collections.nCopies(1, new TaoFestival("北方五道圣诞")));
|
||||
put("12-8", Collections.nCopies(1, new TaoFestival("王侯腊之辰", "王侯腊,此日五帝会於上方玄都玉京")));
|
||||
put("12-16", Arrays.asList(new TaoFestival("南岳大帝圣诞"), new TaoFestival("福德正神诞")));
|
||||
put("12-20", Collections.nCopies(1, new TaoFestival("鲁班先师圣诞")));
|
||||
put("12-21", Collections.nCopies(1, new TaoFestival("天猷上帝圣诞")));
|
||||
put("12-22", Collections.nCopies(1, new TaoFestival("重阳祖师圣诞")));
|
||||
put("12-23", Collections.nCopies(1, new TaoFestival("祭灶王", "最适宜谢旧年太岁,开启拜新年太岁")));
|
||||
put("12-25", Arrays.asList(new TaoFestival("玉帝巡天"), new TaoFestival("天神下降")));
|
||||
put("12-29", Collections.nCopies(1, new TaoFestival("清静孙真君(孙不二)成道")));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 八会日
|
||||
*/
|
||||
public static final Map<String, String> BA_HUI = new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
{
|
||||
put("丙午", "天会");
|
||||
put("壬午", "地会");
|
||||
put("壬子", "人会");
|
||||
put("庚午", "日会");
|
||||
put("庚申", "月会");
|
||||
put("辛酉", "星辰会");
|
||||
put("甲辰", "五行会");
|
||||
put("甲戌", "四时会");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 八节日
|
||||
*/
|
||||
public static final Map<String, String> BA_JIE = new HashMap<String, String>() {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
{
|
||||
put("立春", "东北方度仙上圣天尊同梵炁始青天君下降");
|
||||
put("春分", "东方玉宝星上天尊同青帝九炁天君下降");
|
||||
put("立夏", "东南方好生度命天尊同梵炁始丹天君下降");
|
||||
put("夏至", "南方玄真万福天尊同赤帝三炁天君下降");
|
||||
put("立秋", "西南方太灵虚皇天尊同梵炁始素天君下降");
|
||||
put("秋分", "西方太妙至极天尊同白帝七炁天君下降");
|
||||
put("立冬", "西北方无量太华天尊同梵炁始玄天君下降");
|
||||
put("冬至", "北方玄上玉宸天尊同黑帝五炁天君下降");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 三会日
|
||||
*/
|
||||
public static final String[] SAN_HUI = {"1-7", "7-7", "10-15"};
|
||||
|
||||
/**
|
||||
* 三元日
|
||||
*/
|
||||
public static final String[] SAN_YUAN = {"1-15", "7-15", "10-15"};
|
||||
|
||||
/**
|
||||
* 五腊日
|
||||
*/
|
||||
public static final String[] WU_LA = {"1-1", "5-5", "7-7", "10-1", "12-8"};
|
||||
|
||||
}
|
||||
@@ -15,7 +15,17 @@ public class FotoTest {
|
||||
@Test
|
||||
public void test() {
|
||||
Foto foto = Foto.fromLunar(Lunar.fromYmd(2021, 10, 14));
|
||||
Assert.assertEquals("二五六五年十月十四 (三元降 犯者减寿) (四天王巡行)", foto.toFullString());
|
||||
Assert.assertEquals("二五六五年十月十四 (三元降) (四天王巡行)", foto.toFullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
Foto foto = Foto.fromLunar(Lunar.fromYmd(2020, 4, 13));
|
||||
Assert.assertEquals("氐", foto.getXiu());
|
||||
Assert.assertEquals("土", foto.getZheng());
|
||||
Assert.assertEquals("貉", foto.getAnimal());
|
||||
Assert.assertEquals("东", foto.getGong());
|
||||
Assert.assertEquals("青龙", foto.getShou());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,4 +186,12 @@ public class JieQiTest {
|
||||
Assert.assertEquals("2050-12-07 06:41:00", lunar.getJieQiTable().get("大雪").toYmdHms());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9() {
|
||||
Solar solar = Solar.fromYmd(2021, 12, 21);
|
||||
Assert.assertEquals("冬至", solar.getLunar().getJieQi());
|
||||
Assert.assertEquals("", solar.getLunar().getJie());
|
||||
Assert.assertEquals("冬至", solar.getLunar().getQi());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -387,4 +387,11 @@ public class LunarTest {
|
||||
Assert.assertEquals("厕灶厨 外西南", lunar.getDayPositionTai());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test53() {
|
||||
Solar solar = Solar.fromYmd(2021, 11, 27);
|
||||
Lunar lunar = solar.getLunar();
|
||||
Assert.assertEquals("[嫁娶, 祭祀, 祈福, 求嗣, 开光, 出行, 解除, 出火, 拆卸, 进人口, 入宅, 移徙, 安床, 栽种, 动土, 修造, 纳畜, 入殓, 安葬, 立碑, 除服, 成服]", lunar.getDayYi().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
31
src/test/java/test/TaoTest.java
Normal file
31
src/test/java/test/TaoTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package test;
|
||||
|
||||
import com.nlf.calendar.Lunar;
|
||||
import com.nlf.calendar.Tao;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 道历测试
|
||||
*
|
||||
* @author 6tail
|
||||
*/
|
||||
public class TaoTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Tao tao = Tao.fromLunar(Lunar.fromYmdHms(2021, 10, 17, 18, 0, 0));
|
||||
Assert.assertEquals("四七一八年十月十七", tao.toString());
|
||||
Assert.assertEquals("道歷四七一八年,天運辛丑年,己亥月,癸酉日。十月十七日,酉時。", tao.toFullString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
Tao tao = Tao.fromYmd(4718, 10, 18);
|
||||
Assert.assertEquals("[地母娘娘圣诞, 四时会]", tao.getFestivals().toString());
|
||||
|
||||
tao = Lunar.fromYmd(2021, 10, 18).getTao();
|
||||
Assert.assertEquals("[地母娘娘圣诞, 四时会]", tao.getFestivals().toString());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user