使用System.Globalization将波斯日期转换为格里高利日期和格里高利日期转换为波斯日期
问题描述:
我正在开展一个项目,在该项目中,用户可以为其交易选择格里高利和波斯日期。在数据库中我有两个字段TPersianDate和TGregorianDate,如果用户在插入按钮上选择波斯日期我想将同一日期
转换为格里高利并将其插入TGregorianDate,反之亦然。
I am working on a project where user have Gregorian and Persian Date selection for the their transactions. In database i have two fields TPersianDate and TGregorianDate, if a user select Persian date on the insert button i want to convert the same date to Gregorian and insert it in TGregorianDate and vice versa.
答
在MSDN中查看
PersianCalendar 。它演示了在格里高利和波斯日历中显示日期。这就是你需要的代码。
Take a look at the example in MSDN for PersianCalendar. It demonstrates showing a date in both Gregorian and Persian calendars. That is the code you'll need.