.NET/Answer Detail

Json.NET Deserialize Object change the timezone to local time?

andro
4 Points
2 Posts

I'm using json.net ' JsonConvert' to deserialize a DateTimeOffset, but it is ignoring the specified timezone and converting the datetime to the local offset. For example, as

var content = @"{""startDateTime"":""2018-07-19T14:30:00+09:30""}";

When deserialised using:

var obj = JsonConvert.Deserialize<Object>(content);

The json obj returning a property containing a DateTimeOffset but the value will be 2018-07-19T15:30:00+10:30 i.e. converted to the local timezone instead of preserving the original timezone.

Is there any way to get the value to be parsed as expected so that the resulting DateTimeOffset property will match the supplied one?

Total Answered: 0
Total Marked As Answer: 0
Posted On: 08-Apr-2018 00:35
Share:   fb twitter linkedin
Answers

Blog

Active User (1)

 Log In to Chat