I'm trying to parse incoming date from data source (which cannot be changed). It gives me time in ISO 8601 format example: 2007-04-05T24:00
.
How ever in .Net it fails to parse this as valid time.
The wikipedia states that it should be valid format. Wikipedia ISO 8601
Example from https://stackoverflow.com/a/3556188/645410
How can I do this without a nasty string check hack?
Example (fiddle: http://dotnetfiddle.net/oB7EZx):
var strDate = "2007-04-05T24:00";
Console.WriteLine(DateTime.Parse(strDate, null, DateTimeStyles.RoundtripKind));
Throws:
The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar.