0

Newtonsoft.Json.JsonConvert.DeserializeObject throws invalid Globalization date format exception for following date:

2016-07-26T24:33:37.177Z

Code

DataTable leadDataTable = (DataTable)JsonConvert.DeserializeObject(leadAObj["result"].ToString(),
    typeof(DataTable));

I tried by explicitly passing date format

Code

JsonConvert.DeserializeObject(leadAObj["result"].ToString(), typeof(DataTable),
     new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ" })
7
  • Have you tried settings the JsonSerializerSettings.DateFormatString property to the required datetime format? Commented Aug 19, 2016 at 11:43
  • I passed IsodateTimeConverter object as third parameter to Deserialize Object method, New Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ" } Commented Aug 19, 2016 at 11:45
  • 1
    That is an invalid ISO8601 time. There is no 24:33, it should be 00:33. You should fix the code that generates the JSON string Commented Aug 19, 2016 at 11:56
  • To put it lightly, the 25th hour may be valid for movies but not for ISO dates Commented Aug 19, 2016 at 11:59
  • I'm getting this data from REST api call, with out Deserialize how could I update that data, please suggest some way, I don't have acces to update that api code Commented Aug 19, 2016 at 12:00

1 Answer 1

4

The time is 33 minutes past midnight is that what you are expecting?

Shouldn't it be 00:33 not 24:33

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.