Monday, October 22, 2007

4411.aspx

DateTime is not supported by gregorian calendar

I got this "new" exception when I was consuming one RSS feed:



System.FormatException was unhandled
 Message="The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar."
 Source="mscorlib"
 StackTrace:
      at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
      at System.DateTime.Parse(String s)


System.DateTime.Parse chocked on this input date 2007-09-13T24:28:51Z


Forcing the current culture to System.Globalization.CultureInfo.InvariantCulture did not help so I ended up with this ugly hack:
 dateString = dateString.Replace("T24:", "T00:")


Let me know if you find a cleaner solution.

1 comment:

  1. Well, I don't have a cleaner solution but THANKS for posting that. :)

    I was stumped until I read your post.

    ReplyDelete