I have some data coming from an XML document, such as 2012-12-06T24:00.
The problem is when I try to convert it : 24:00 doesnt exist. So :
DateTime.Parse(myDateTimeString).Hour
give to me this Exception: System.FormatException: The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar.
How can I fix it?
The solution I think about is to replace (string) T24 with T00, which looks horrible…
DateTimecannot handle this. You have to “sanitize” your string before callingParseand handle the overflow (depending on what “24:00” actually means):EDIT: added the “overflow”-part.