java農曆演算法

2021-05-17 20:49:18 字數 1397 閱讀 7921

final public long getlunarint()

//傳出y年m月d日對應的農曆.year0 .month1 .day2 .yearcyl3 .moncyl4 .daycyl5 .isleap6

if(offset<0)

lunarint[0] = i;

lunarint[3] = i-1864;

leap = leapmonth(i); //閏哪個月

lunarint[6] = 0;

for(i=1; i<13 && offset>0; i++)

else

//解除閏月

if(lunarint[6]==1 && i==(leap+1)) lunarint[6] = 0;

offset -= temp;

if(lunarint[6] == 0) lunarint[4] ++;

}if(offset==0 && leap>0 && i==leap+1)

else

}if(offset<0)

lunarint[1] = i;

lunarint[2] = offset + 1;

return lunarint;

}final public string getlunarstr()

string lday = "";

if(lun[2]==10)

lday="初十";

int two = (int)((lun[2])/10);

if(two==0)

lday = "初";

if(two==1)

lday = "十";

if(two==2)

lday = "廿";

if(two==3)

lday = "卅";

int one = (int)(lun[2]%10);

switch(one)

lunarstr[0]=animalsyear((int)lun[0]);

lunarstr[1]=lmonth;

lunarstr[2]=lday;

lunarstr[3]=cyclical((int)lun[0]);

lunarstr[4]=cyclicalm((int)lun[4]);

lunarstr[5]=cyclicalm((int)lun[5]);

lunarstr[6]=lun[6]==0?"":"閏";

return lunarstr;

}public void printlunar()

public static void main(string args)

}執行結果:

公曆:2023年12月31日

農曆:2023年11月16日

農曆:牛年十一月十六, 己丑年丙子月庚戌日

農曆演算法簡介以及公式

農曆演算法簡介以及公式 有關農曆的東西有以下幾篇文章 計算某天是星期幾 c 農曆演算法簡介以及公式 農曆中天干地支的計算 c 農曆一百年演算法 1921 2021 c語言 農曆兩百年演算法 1901 2100 c語言 一 節氣的計算 先給節氣進行編號,從近日點開始的第乙個節氣編為0,編號如下及其相應...

C 實現的農曆演算法

農曆演算法簡介以及公式 一 節氣的計算 先給節氣進行編號,從近日點開始的第乙個節氣編為0,編號如下及其相應的月份如下 0 小寒 臘月 6 清明 三月 12 小暑 六月 18 寒露 九月 1 大寒 臘月 7 穀雨 三月 13 大暑 六月 19 霜降 九月 2 立春 正月 8 立夏 四月 14 立秋 七...

C 公曆轉農曆演算法

using system using system.collections.generic using system.text 地支 private static string dizhi 十二生肖 private static string shengxiao 農曆日期 private stati...