/egilh

Learning by doing

DateTime is not supported by gregorian calendar

Posted on Monday, October 22, 2007 6:54 AM

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.




Feel free to drop a few cents in the tip jar if this post saved you time and money

Feedback

# re: DateTime is not supported by gregorian calendar

8/18/2008 10:37 PM by aikeru

Well, I don't have a cleaner solution but THANKS for posting that. :)
I was stumped until I read your post.


Post Comment
Title
 

Name
 

Url

Protected by Clearscreen.SharpHIPEnter the code you see:
Comment