一、层次结构

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();//;五

中文日历Calendar的更多相关文章

  1. [习题]日历(Calendar)控件的障眼法(.Visible属性),使用时才出现?不用就消失?

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/09/02/calendar_icon_visible.aspx [习题]日历(Cal ...

  2. jQuery ui 中文日历

    jQuery ui 中文日历 <link href="css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet&qu ...

  3. [习题]输入自己的生日(年/月/日)#2 -- 日历(Calendar)控件的时光跳跃,一次跳回五年、十年前?--TodaysDate属性、VisibleDate属性

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/06/10/calendar_visibledate_birthday_dropdow ...

  4. [Swift实际操作]七、常见概念-(7)日历Calendar和日期组件DateComponents

    本文将为你演示日历和日期组件的使用.通过日历的日期部件,可以获得日期的各个部分. 首先引入需要用到的界面工具框架 import UIKit 初始化一个日期对象,其值为当前的日期. let dt = D ...

  5. [Swift实际操作]七、常见概念-(8)日历Calendar和时区TimerZone

    本文将为你演示日历的一些属性,以及如何利用日历,查询是否为昨天.今天和明天. 首先引入需要用到的界面工具框架 import UIKit 然后生成一个日历对象,并获得用户当前的日历. var calen ...

  6. day18 时间:time:,日历:calendar,可以运算的时间:datatime,系统:sys, 操作系统:os,系统路径操作:os.path,跨文件夹移动文件,递归删除的思路,递归遍历打印目标路径中所有的txt文件,项目开发周期

    复习 ''' 1.跨文件夹导包 - 不用考虑包的情况下直接导入文件夹(包)下的具体模块 2.__name__: py自执行 '__main__' | py被导入执行 '模块名' 3.包:一系列模块的集 ...

  7. 七:日期类Date、日期格式化SimpleDateFormat、日历Calendar

    日期的格式转换:

  8. Java Calendar实现控制台日历

    public static void main(String[] args) throws IOException { //初始化日历对象 Calendar calendar = Calendar.g ...

  9. Java中的Calendar日历用法详解

    第一部分 Calendar介绍 public abstract class Calendar implements Serializable, Cloneable, Comparable<Cal ...

随机推荐

  1. jira常用配置

    1.关闭注册入口 系统->一般配置->运行模式:私有 2.分享给用户组是,看不到部分用户组的时候,只需要把你的账号添加该分组即可. 3.为项目分配权限,问题-->问题属性——> ...

  2. LeetCode 144. 二叉树的前序遍历(Binary Tree Preorder Traversal)

    144. 二叉树的前序遍历 144. Binary Tree Preorder Traversal 题目描述 给定一个二叉树,返回它的 前序 遍历. LeetCode144. Binary Tree ...

  3. lnmp二级域名配置相关

    阿里云那域名解析那有误读 我在偏远的电信网选择中国联通解析死活解析不出来 以上这么配置就对了....选择默认.瞬间解析出来.... 出于对nginx 配置不够熟悉 后来一点点理出来. 不带www 也正 ...

  4. MySQL基础操作(二)

    MySQL基础操作 一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用.注意:使用视图时 ...

  5. 剑指offer41:所有和为S的连续正数序列,例如,有多少种连续的正数序列的和为100

    1 题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久 ...

  6. go tcp发送网络请求

    //发送http请求 package main import ( "fmt" "net" "io" ) func main () { //使 ...

  7. 开始Jupyter Notebooks

    开始Jupyter Notebooks 安装Anaconda 因为不能有空格,所以没有选C:\Program Files 认识Jupyter Notebooks 修改 jupyter notebook ...

  8. 音视频入门-13-使用开源库生成PNG图片

    * 音视频入门文章目录 * RGB-to-PNG 回顾 上一篇 [手动生成一张PNG图片] 根据 [PNG文件格式详解] 一步一步地手动实现了将 RGB 数据生成了一张 PNG 图片. 有许多开源的 ...

  9. springboot笔记04——读取配置文件+使用slf4j日志

    前言 springboot常用的配置文件有yml和properties两种,当然有必要的时候也可以用xml.我个人更加喜欢用yml,所以我在这里使用yml作为例子.yml或properties配置文件 ...

  10. 定时任务cron表达式详解

    参考自:https://blog.csdn.net/fanrenxiang/article/details/80361582 一 cron表达式 顺序 秒 分 时 日期 月份 星期 年(可选) 取值 ...