I am trying to parse a French date to a DateTime object with no luck so far. Is there a way to do that?
String foo = "mar, 20 avr 2010 09:00:00 -0500";
I’ve already tried parsing with a different culture and changing the culture of the thread.
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA",true);
CultureInfo culture = new CultureInfo("fr-CA",true);
DateTime.Parse(foo,culture,DateTimeStyles.AdjustToUniversal);
You can only parse (with Parse or ParseExact) what you can create when formatting a DateTime.
The closest custom format specifier to your example input is probably something like this:
Code:
This produces the following result:
As you can see, the short day and short month specifier (
dddandMMM) add a.after the name, and the time-zone specifier (zzz) inserts a:.I believe it’s not possible to trick ToString into generating the desired output, and thereby also not to parse the result with ParseExact. I guess you have to parse the string yourself using plain old string manipulation.