Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

System.DateTime.Parse("Thu, 05 May 2005 14:50:52 EDT") Fails

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael S. Scherotter - 05 May 2005 23:20 GMT
How do I use the .Net 1.1 System.DateTime so that it will parse the string

"Thu, 05 May 2005 14:50:52 EDT"

Currently System.DateTime.Parse("Thu, 05 May 2005 14:50:52 EDT") Fails with

a FormatException:
The string was not recognized as a valid DateTime.  There is a unknown word
starting at index 26.

Thanks,
Michael

Signature

Michael S. Scherotter
Business Solutions Architect
Mindjet LLC

Stephany Young - 06 May 2005 00:06 GMT
The basic answer is simple. Index 26 is where 'EDT' starts and
DateTime.Parse is never going to handle an abbreviation for any timezone.

The answer you want to hear is a little more complicated and depends upn
where you are at the time you attempt to parse the value. I am going to
assume that the value is always in the format, i.e., always has a 3
character timezone code at the end.

If you are always in the timezone indicated by the timezone code in the
string then you can disregard it completely. Simply remove the last 3
characters from the value, trim any whitespace from it directly prior to
parsing and treat the result as a local date/time.

If you are NOT always in the timezone indicated by the timezone code then
you need to handle the timezone part yourself. For the EDT timezone you need
to modify the value to read "Thu, 05 May 2005 14:50:52 -4:00". For the EST
timezone you need to modify the value to read "Thu, 05 May 2005
14:50:52 -05:00". Once you have done this you need to parse the value using
DateTime.ParseExact("ddd, dd MMM yyyy HH:mm:ss zzz"). The result will be the
value is respect of the indicated timezone.

> How do I use the .Net 1.1 System.DateTime so that it will parse the string
>
[quoted text clipped - 10 lines]
> Thanks,
> Michael
User - 06 May 2005 03:04 GMT
What about daylight savings time?

> The basic answer is simple. Index 26 is where 'EDT' starts and
> DateTime.Parse is never going to handle an abbreviation for any timezone.
[quoted text clipped - 36 lines]
> > Business Solutions Architect
> > Mindjet LLC
Stephany Young - 06 May 2005 03:49 GMT
My fourth paragraph specifically mentions daylight saving and non-daylight
saving time.

> What about daylight savings time?
>
[quoted text clipped - 43 lines]
>> > Business Solutions Architect
>> > Mindjet LLC

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.