1

I am writing an api that will talk with a third party website. It expects the date in a format of 2016-09-24T00:00:00Z with only the date portion changing (the time is always 00:00:00Z regardless of time or timezone).

I am using Angular to convert it (and then calling toString()) to the correct format and am calling JSON.stringify on it and then passing it to my web method.

In my web method I call to convert the data to a string.

var registrationExpiryFull = indata["registrationExpiryFull"].ToObject<string>();

However after that line executes registrationExpiryFull has formatted the date from 2016-09-24T00:00:00Z to 09/23/2016 00:00:00. The first picture shows the string that is coming into the method and the second picture shows the formatted date.

Why does my string that I pass in get converted to another string?

Before we call ToObject enter image description here After enter image description here

Mathemats
  • 1,185
  • 4
  • 22
  • 35
  • Can you not just call ToString rather than ToObject? – tomliversidge Sep 02 '16 at 06:42
  • Also looks like you are calling ExpiryShort in the example here so you are comparing two different things – tomliversidge Sep 02 '16 at 06:43
  • It's probably something like [this](https://stackoverflow.com/questions/35138346/jtoken-get-raw-original-json-value/35141787) or [this](https://stackoverflow.com/questions/35166060/json-net-get-specific-json-date-value) but without a [mcve] it's hard to be sure. Also, please try to share the actual code, JSON or exception output, not a bitmap snapshot. See [here](https://meta.stackoverflow.com/a/285557) for reasons. – dbc Sep 02 '16 at 06:45
  • @tomliversidge Nah, that's just my IDE highlighting. Both of the debug images reference registrationExpiryFull. – Mathemats Sep 02 '16 at 06:46
  • @dbc That first link is the answer. Thank you – Mathemats Sep 02 '16 at 06:46

0 Answers0