Wednesday, 15 August 2012

c# - How do I parse an RFC822 date in .NET? -


I have the following timeline string given by the Twitter API:

" Thu Apr 26 11:38:36 +0000 2012 "

I need to convert it to the datetime object, so I can see the ParseExact I am calling with a custom format specifier:

  CultureInfo Provider = CultureInfo.InvariantCulture; Datetime Publish Data = DateTime Purse AXt (Twitter ["Created"]. Toasting (), "DAD MMM DD HH: MM: SS Z Yay", provider);   

However, for any type of z , zz or , a FormatException Exception increments zzz for time zone :

The string was not recognized as a valid date time.

Given that this format specification is expecting the time zone to be in the zz: zz format, where time for delimiting hours and minutes There is a colon in the zone.

I have examined other questions on stack overflow like:

  • And of these Nobody really helps.

    Is there a time zone specification that I can parse that format correctly?

    This is not quite stupid.

    The problem hour was the specifier. I use "hh" which is 12 hour clock time. For 24 hours, I should have used "HH".

    Keep in mind the subtle difference.

    Changing that it works as expected

No comments:

Post a Comment