I understand different cultures specify dates differently. Some put day before month (27/10/2009 vs. 10/27/2009) and others use dots instead of slashes (10.27.2009 vs. 10/27/2009). However, is there anything special that needs to be done regarding the year? Do non-Christian cultures refer to the same numeric year (2009) as Christian cultures? I created a simple C# app and did a toString on the current date, changed the language/culture to Arabic and it displays the same thing. Maybe the year is a globally accepted standard???
A:
Use the ToString()
overload which takes an IFormatProvider
and pass in CultureInfo.CurrentCulture
and the date will format appropriately.
Jesse C. Slicer
2009-10-28 01:06:57
CurrentUICulture is used for looking up strings in resource files. You should use CurrentCulture instead.
Greg
2009-10-28 01:21:53
Though I don't believe this will do anything to adjust into the Chinese, Jewish or Arabic numeric years. My memory may be a bit rusty, but I don't think Windows supports any calendar (regardless of date format) than Gregorian.
Jesse C. Slicer
2009-10-28 01:35:53