java中怎么把公历日期转成农历日期

 我来答
Mexico卡卡
2017-12-14 · TA获得超过1万个赞
知道大有可为答主
回答量:1.3万
采纳率:98%
帮助的人:1841万
展开全部

Excel可以实现中阳历日期转换成阴历日期,具体操作如下:

一、使用工具:excel2010

二、操作步骤:

1、假设A1为阳历日期,B1为转换后的阴历日期值,点击B1单元格输入以下代码:

=CHOOSE(MOD(YEAR(LEFT(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),4)&"-"&MID(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),6,2)&"-"&RIGHT(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),2))-1900,10)+1,"庚","辛","壬","癸","甲","乙","丙","丁","戊","己")&CHOOSE(MOD(YEAR(LEFT(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),4)&"-"&MID(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),6,2)&"-"&RIGHT(TEXT(A1,"[$-130000]yyyy年mm月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"dd"),2))-1900,12)+1,"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥")&TEXT(A1,"[dbnum1][$-130000]年m月"&IF(--TEXT(A1,"[$-130000]d")<11,"初","")&TEXT(A1,"[dbnum1][$-130000]d日"))

如图:

2、输入代码后按回车键,这时B1返回A1对应的阴历日期,如图:

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式