C# DateTime.ParseExact throwing format exception
Posted
by
Rob
on Stack Overflow
See other posts from Stack Overflow
or by Rob
Published on 2010-12-21T20:52:15Z
Indexed on
2010/12/21
20:54 UTC
Read the original article
Hit count: 190
I'm developing an .NET4 webapplication using MVC3.
Let's say i'm getting the following DateTime as string from an XML-feed. The xml feed is being read by my application and i'm looping through all it's descendants. The DateTime i'm receiving is begin returned in the following format (as string);
var myDateTime = "Sun Dec 19 11:45:45 +0000 2010"
I'm using the piece of code below to try and parse the DateTime string i mentioned above to a valid DateTime format (preferably dutch)
var CorrectDateTime = DateTime.ParseExact(myDateTime , "dd MMM yyyy HH:mm:ss", CultureInfo.InvariantCulture);
When trying to execute this code i'm facing an formatexception. Somebody has got any ideas?
© Stack Overflow or respective owner