// ====== 传回农历 y年闰月的天数 final private static int leapDays( int y) { if (leapMonth(y) != 0 ) { if ((lunarInfo[y - 1900 ] 0x10000 ) != 0 ) return 30 ; else return 29 ; } else return 0 ; }
// ====== 传回农历 y年闰哪个月 1-12 , 没闰传回 0 final private static int leapMonth( int y) { return ( int ) (lunarInfo[y - 1900 ] 0xf ); }
// ====== 传回农历 y年m月的总天数 final private static int monthDays( int y, int m) { if ((lunarInfo[y - 1900 ] ( 0x10000 m)) == 0 ) return 29 ; else return 30 ; }
// ====== 传回农历 y年的生肖 final public String animalsYear() { final String[] Animals = new String[] { "鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"}; return Animals[(year - 4 ) % 12 ]; }
// ====== 传入 月日的offset 传回干支, 0=甲子 final private static String cyclicalm( int num) { final String[] Gan = new String[] { "甲","乙","丙","丁","戊","己","庚","辛","壬","癸"}; final String[] Zhi = new String[] { "子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"}; return (Gan[num % 10 ] + Zhi[num % 12 ]); }
// ====== 传入 offset 传回干支, 0=甲子 final public String cyclical() { int num = year - 1900 + 36 ; return (cyclicalm(num)); }
/** */ /** * 传出y年m月d日对应的农历. * yearCyl3:农历年与1864的相差数 ? * monCyl4:从1900年1月31日以来,闰月数 * dayCyl5:与1900年1月31日相差的天数,再加40 ? * @param cal * @return */ public Lunar(Calendar cal) { //cal.add(cal.get(Calendar.DAY_OF_MONTH),1); @SuppressWarnings( " unused " ) int yearCyl, monCyl, dayCyl; int leapMonth = 0 ; Date baseDate = null ; try { baseDate = chineseDateFormat.parse( " 1900年1月31日 " ); } catch (ParseException e) { e.printStackTrace(); // To change body of catch statement use Options | File Templates. }