如何公历日期转换为波斯日期? [英] How convert Gregorian date to Persian date?

查看:128
本文介绍了如何公历日期转换为波斯日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要定制的公历日期转换为波斯日期在C#中。
为例,我有这样内容的字符串:

I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents:

string GregorianDate = "Saturday, October 24, 2013";

现在我想有:

字符串PersianDate =پنجشنبه2آبان1392;

string PersianDate = پنج‌شنبه 2 آبان 1392 ;

字符串PersianDate = 1392年8月2日

string PersianDate = 1392/08/02

感谢

推荐答案

使用的PersianCalendar:

Use the PersianCalendar:

string GregorianDate = "Thursday, October 24, 2013";
DateTime d = DateTime.Parse(GregorianDate);
PersianCalendar pc = new PersianCalendar();
Console.WriteLine(string.Format("{0}/{1}/{2}", pc.GetYear(d), pc.GetMonth(d), pc.GetDayOfMonth(d)));



我改变了一天至周四,因为这是2013年10月,24日。

I changed the day to Thursday since that was the 24th of October, 2013.

这篇关于如何公历日期转换为波斯日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆