阅读230 返回首页    go 阿里云 go 技术社区[云栖]


公历转农历函数

    class Program
    {
        static void Main(string[] args)
        {
            System.Globalization.ChineseLunisolarCalendar chineseLunisolarCalendar = new System.Globalization.ChineseLunisolarCalendar();
            DateTime date = DateTime.Now;  
            int year = chineseLunisolarCalendar.GetYear(date);
            int month = chineseLunisolarCalendar.GetMonth(date);
            int day = chineseLunisolarCalendar.GetDayOfMonth(date);
            Console.WriteLine(string.Format("公历:{0} 农历:{1}", date.ToString("yyyy-MM-dd"), (year + "-" + month + "-" + day)));
            Console.Read();
        }
    }

最后更新:2017-04-02 06:52:21

  上一篇:go JAVASCRIPT学习笔记基础(四)
  下一篇:go Android 近百个项目的源代码,覆盖Android开发的每个领域