469,271 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Problem with DateTime.Parse

Hello,

why does this not work (the OS runs with german settings):

DateTimeFormatInfo dtFI = new DateTimeFormatInfo();

dtFI.FullDateTimePattern = "ddd MMM dd HH:mm:ss yyyy";
dtFI.AbbreviatedDayNames = new string[] {"Mon", "Tue", "Wed",
"Thu", "Fri", "Sat", "Sun"};
dtFI.AbbreviatedMonthNames = new string[] {"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
return DateTime.Parse("Fri Aug 01 09:03:43 2003", dtFI);

Thanks for any suggestion.

Tobias
Jul 19 '05 #1
2 12337
Hello Tobias,

Try a simpler solution:

System.IFormatProvider format =
new System.Globalization.CultureInfo("en-US", true);

return DateTime.Parse("Fri Aug 01 09:03:43 2003", format);

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Unit Testing and Integration Environment
http://x-unity.miik.com.ua
Deliver reliable .NET software

"Tobias Olbort" <To****@Olbort.de> wrote in message
news:bc**************************@posting.google.c om...
Hello,

why does this not work (the OS runs with german settings):

DateTimeFormatInfo dtFI = new DateTimeFormatInfo();

dtFI.FullDateTimePattern = "ddd MMM dd HH:mm:ss yyyy";
dtFI.AbbreviatedDayNames = new string[] {"Mon", "Tue", "Wed",
"Thu", "Fri", "Sat", "Sun"};
dtFI.AbbreviatedMonthNames = new string[] {"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
return DateTime.Parse("Fri Aug 01 09:03:43 2003", dtFI);

Thanks for any suggestion.

Tobias


Jul 19 '05 #2
Hello Dmitriy,

thanks for your reply.

With the addition of the pattern it works now fine.

Like this:

return DateTime.ParseExact("Fri Aug 01 09:03:43 2003", "ddd MMM dd
HH:mm:ss yyyy", new System.Globalization.CultureInfo("en-US", true));

Tobias

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by ChrisM | last post: by
4 posts views Thread by Hans Merkl | last post: by
5 posts views Thread by Thomas Scheiderich | last post: by
2 posts views Thread by scorpion53061 | last post: by
11 posts views Thread by Cor Ligthert | last post: by
2 posts views Thread by Mike Collins | last post: by
5 posts views Thread by js | last post: by
4 posts views Thread by =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post: by
3 posts views Thread by Jeff | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.