我想将 Hijri (阿拉伯语)日期转换为美国(英文)日期格式..
Ex,Current Hijri Date - > 07-08-1434 (dd-MM-yyyy)
我想像这样转换 - > 16-06-2013 (dd-MM-yyyy)
答案 0 :(得分:-1)
使用此功能......它可以帮助你: 首先创建一个字符串数组来存储u:
的所有格式private string[] allFormats={"yyyy/MM/dd","yyyy/M/d",
"dd/MM/yyyy","d/M/yyyy",
"dd/M/yyyy","d/MM/yyyy","yyyy-MM-dd",
"yyyy-M-d","dd-MM-yyyy","d-M-yyyy",
"dd-M-yyyy","d-MM-yyyy","yyyy MM dd",
"yyyy M d","dd MM yyyy","d M yyyy",
"dd M yyyy","d MM yyyy"};
然后:
private CultureInfo arCul;
private CultureInfo enCul;
private HttpContext cur;
并最终使用此功能: (字符串格式:使用你想要的特定格式!AND string hijr:Hijri Date to string)
public string HijriToGreg(string hijri,string format)
{
if (hijri.Length<=0)
{
cur.Trace.Warn("HijriToGreg :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(hijri,
allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString(format,enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("HijriToGreg :"+hijri.ToString()+"\n"+ex.Message);
return "";
}
}
我希望它可以帮助......