heqiao2010 / lunarcalendar Goto Github PK
View Code? Open in Web Editor NEW**农历的Java实现,支持约300年公历范围:1850-02-12到2150-12-31;一个Java类不到1000行,不依赖任何第三方库。
Home Page: https://github.com/heqiao2010/LunarCalendar
**农历的Java实现,支持约300年公历范围:1850-02-12到2150-12-31;一个Java类不到1000行,不依赖任何第三方库。
Home Page: https://github.com/heqiao2010/LunarCalendar
import com.github.heqiao2010.lunar.LunarCalendar
val lunar = new LunarCalendar(2021, 12, 30, false)
val today = LunarCalendar.lunar2Solar(lunar.getLyear(), lunar.getLmonth(), lunar.getLdate(), lunar.isLeapMonth());
System.out.println(lunar.getFullLunarName + " <====> " + today.getTime)
这里输出是
二〇二二年正月初一 壬寅年 虎 <====> Tue Feb 01 12:01:31 CST 2022
腊月三十(实际上这一年没有这一天)变成了正月初一
1954-11-25
【马年】冬月初一
甲午年 乙亥月 乙酉日
错了吧,
1900年是庚子年,怎么会是庚寅年?
我拿了其他版本的对比结果。
发现有很多处不相符。
建议检查一下。
比如:
date: "1956-12-02"
year: "丙申年"
month: "十月"
day: "卅十"
date: "1956-12-2"
IMonthCn: "冬月"
IDayCn: "初一"
add(年/月/日, 数量) 的方法只有在日上是正确的,在月(农历月?)年(农历年)上是不正确的。比如
农历二〇一三年三月初一
加一年是 农历 二〇一四年三月十一
减一年是 农历 二〇一二年三月二十
我这边想做一个按按农历加减的,不知道 add 方法是否本意是与我描述的一样。
Should be:
other.lunarMonth = getLunarMonth();
java项目下 resource文件夹里的都是测试使用的对照表,但是被错误的打包进了jar包里,导致jar包很大
建议把测试用的文件放到对应的测试资源文件夹
构造器 (int year, int month, int day, boolean isLunar, boolean isLeapMonth)
在调用getSolar之前未初始化solar字段,导致空指针异常。应该在这个方法第一行加一个:
solar =new GregorianCalendar();
运行下面的代码,想得到农历2018年8月20对应的公历:
Calendar solar = LunarCalendar.lunar2Solar(2018, 7, 20, false);
System.out.println(df.format(solar.getTime()));
System.out.println(LunarCalendar.solar2Lunar(solar));
输出如下,得到的公历再转化为农历有2天的偏差:
2018-10-01
二〇一八年八月廿二
结果成了农历2018年8月22
任意选择某一年
如农历2019.08.15
这里要额外传是否闰月,这个如何获取呢?
Calendar today = LunarCalendar.lunar2Solar(lunar.getLyear(), lunar.getLmonth(), lunar.getLdate(), lunar.isLeapMonth());
你好
我在2017/8/5農曆丁由酉年潤六月十四日,做這樣的操作得出的數據是錯誤的。
LunarCalendar chDate=new LunarCalendar();
LunarCalendar nextChDate=new LunarCalendar();
nextChDate.add(Calendar.DATE,1);
Log.d(getClass().getName(), "This Date num="+chDate.getDate());
Log.d(getClass().getName(), "Next Date num="+nextChDate.getDate());
列印結果:
This Date num=14
Next Date num=13
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.