公历转农历函数

    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();
        }
    }

你可能感兴趣的:(公历转农历函数)