Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, June 21, 2012 8:56 AM | 1 vote
Hi Everyone,
Would like to ask why the output datetime format in Arabic locale seems to be not a valid date..
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(1025);
DateTime dateArabic = DateTime.Now;
//Output: Date = {01/08/33 12:00:00 ص}
In French, it seems to look ok.
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(1036);
DateTime dateFrench = DateTime.Now;
//Output: Date = {21/06/2012 00:00:00}
Any Idea?
Thanks in advance!
Best Regards, Juan Genaro
All replies (6)
Thursday, June 21, 2012 9:30 AM ✅Answered
use following piece of code to know exactly what is the pattern for each locale
CultureInfo culture = new CultureInfo("ar");
string datepattern = culture.DateTimeFormat.LongDatePattern;
Mark Answered, if it solves your question and Vote if you found it helpful.
Rohit Arora
Friday, June 22, 2012 7:38 AM ✅Answered
According to RobitArora and Louis's suggestion, you will need to culture info's LongDatePattern format, then set the current thread's culture , if you cannot clear about how to apply this suggestion into codes, you can ref my this demo:
CultureInfo culture = new CultureInfo("ar");
string datepattern = culture.DateTimeFormat.LongDatePattern;
DateTimeFormatInfo datetimeFormatInfo = new DateTimeFormatInfo();
datetimeFormatInfo.LongDatePattern = "yyyy-MM-dd";
culture.DateTimeFormat = datetimeFormatInfo;
Thread.CurrentThread.CurrentCulture = culture;
DateTime dateArabic = DateTime.Now;
Have a nice weekend!
Mike Zhang[MSFT]
MSDN Community Support | Feedback to us
Friday, June 22, 2012 10:16 AM ✅Answered
Juan,
I'm no expert in Arabic, all I know that there is a special class to handle Arabic date an times.
http://msdn.microsoft.com/en-us/library/system.globalization.umalquracalendar.aspx
Success
Cor
Thursday, June 21, 2012 12:05 PM
The general datetime format uses the ShortDatePattern, which is dd/MM/yy for arabic culture.
Saturday, June 23, 2012 5:53 PM
Thanks a lot Guys! this helped.
Best Regards, Juan Genaro
Monday, June 25, 2012 2:54 AM
You're welcome!
Mike Zhang[MSFT]
MSDN Community Support | Feedback to us