一、层次结构

Object<-----Calendar<-----EastAsianLunisolarCalendar<-----ChineseLunisolarCalendar(农历)

二、用法

1、支持的最大,最小日期

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.MinSupportedDateTime.ToString("");//02/19/1901 00:00:00
s2=cc.MaxSupportedDateTime.ToString("");//01/28/2101 23:59:59

2、单位农历天数

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetMonthsInYear(DateTime.Now.Year).ToString();//12,一年中有几个月,13表示当年有闰月。
s2=cc.GetDaysInYear(DateTime.Now.Year).ToString();//354,一年中有多少天
s3=cc.GetDaysInMonth(DateTime.Now.Year,DateTime.Now.Month).ToString();//29 ,当月中有多少天

3、天干、地支

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetSexagenaryYear(DateTime.Now ).ToString();//36,天干
s2=cc.GetTerrestrialBranch().ToString();//12,地支

4、农历年、月、日

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetYear(DateTime.Now).ToString();//;2019
s2=cc.GetMonth(DateTime.Now).ToString();//;5,注意:其返回值为1-13的数,如果该年四月有闰月,4月返回4,闰4月则返回5
s3=cc.GetDayOfMonth(DateTime.Now).ToString();//;23

5、闰年与闰月

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.IsLeapYear(DateTime.Now.Year).ToString();//;False
s2=cc.GetLeapMonth(DateTime.Now.Year).ToString();//;0,注意:表示所闰月份。如果返回5,表示闰4月。

6、显示农历大写月份

string[] monthName = {"正",  "二", "三", "四", "五", "六", "七", "八", "九", "十", "东", "腊" };
System.Globalization.ChineseLunisolarCalendar cc = new System.Globalization.ChineseLunisolarCalendar();
int currentMonth = cc.GetMonth(DateTime.Today);
int leapMonth = cc.GetLeapMonth(DateTime.Today.Year);
string realMonth;
if (currentMonth < leapMonth)
realMonth = monthName[currentMonth];
else if (currentMonth == leapMonth)
realMonth = "闰" + monthName[currentMonth - ];
else
realMonth = monthName[currentMonth - ];
s1 = realMonth.ToString();//;五

最新文章

  1. android基础知识进阶
  2. C# Winform中如何获取文件名与文件路径
  3. SQL Server 2014 安装小记
  4. C++Primer 第七章
  5. iOS开发之Xcode 6 国际化
  6. 【UEditor】远程上传图片到【七牛云存储】
  7. weblogic 安装与配置
  8. Spring中整合Titles
  9. Makefile与shell脚本的区别
  10. Android实现左右滑动指引效果
  11. 可以改变文本行距(行间距)的Label
  12. 安装、设置与启动MySql绿色版的方法
  13. js---DOM元素节点
  14. servlet规范核心类图
  15. 201521123082 《Java程序设计》第6周学习总结
  16. Oracle计算两天两个日期间相差的天数
  17. 初识:java虚拟机的内存划分
  18. redis分布式锁(转)
  19. apicloud监听返回键(安卓试过)
  20. 阿里云安装elastcsearch后外网访问配置

热门文章

  1. [转帖]理解k8s 的 Ingress
  2. scau 9502 ARDF一个变量的问题
  3. hdu 2167 题解
  4. php面向对象之封装
  5. 关于python的一次性能调优过程
  6. go String方法的实际应用
  7. 使用Docker搭建svn服务器教程
  8. 小游戏UFO Fled
  9. java 线程实现、线程暂停和终止 、线程联合join、线程基本信息获取和设置、线程优先级
  10. Mybatis的实现原理