I have the following Arabic date in a Umm Al-Qura calendar that I want to parse in a .NET DateTime object:
الأربعاء, 17 ذو الحجة, 1436
This date is equivalent to September 30, 2015 in the Gregorian calendar.
I tried the following "standard" C # code to parse this date, but without success:
var cultureInfo = new CultureInfo("ar-SA"); cultureInfo.DateTimeFormat.Calendar = new UmAlQuraCalendar(); // the default one anyway var dateFormat = "dddd، dd MMMM، yyyy"; //note the ، instead of , var dateString = "الأربعاء، 17 ذو الحجة، 1436"; DateTime date; DateTime.TryParseExact(dateString, dateFormat, cultureInfo.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces, out date);
No matter what I do, the result of TryParseExact always false . How to parse this string correctly in .NET?
By the way, if I start with a DateTime object, I can create the exact date string above using ToString() overload on DateTime without any problems. I just can't do it differently.
source share