473,413 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

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 12499
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate...
14
by: ChrisM | last post by:
Could anyone please tell me the difference between these 2 lines: myDate = DateTime.Now; and myDate = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy")); Seeing as later on in the...
4
by: Hans Merkl | last post by:
Does anybody know of a library that can handle strings pf various formats and conver them to a DateTime value? The strings are coming from a webform and I can't restrict the input (it's not my...
5
by: Thomas Scheiderich | last post by:
I am having a problem with a Datatable access. This statement apparently works fine: response.write(GetRows.Rows(ktr)(1)) and this statement does not: if e.day.date = GetRows(ktr)(1) then
2
by: scorpion53061 | last post by:
What I thought would be pretty easy has turned out not to be. I have three variables. Actiontime is formatted as 08/11/2004 11:03PM Actiontime JobStreamStart (11:00:00PM) JobStreamEnd...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am having a problem formatting a string when the time is in format hh.mm.ss - used in Europe Parse seems ok when the date uses "/" or "." as seperator but I get an exception when time...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.