public class EmployementHistory
{
public string EmployeeName { get; set; }
public DateTime PositionChangeDate { get; set; }
}
{ "employeename":"Tom", "PositionChangeDate":"20180710T135034Z" }
As yyyyMMddTHHmmssZ is an ISO8601 format, it should be supported by default, according to IsoDateTimeConverter documentation
{System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at Newtonsoft.Json.Converters.IsoDateTimeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
var json = "{ \"employeename\":\"Tom\", \"PositionChangeDate\":\"20180710T135034Z\" }";
var serializeSettings=new JsonSerializerSettings();
serializeSettings.Converters.Add(new IsoDateTimeConverter());
var result= JsonConvert.DeserializeObject<EmployementHistory>(json,serializeSettings);
yyyyMMddTHHmmssZ is an ISO8601 format
No it isn't
https://en.wikipedia.org/wiki/ISO_8601
In representations for interchange, dates and times are arranged so the largest temporal term (the year) is placed to the left and each successively smaller term is placed to the right of the previous term. Representations must be written in a combination of Arabic numerals and certain characters (such as "-", ":", "T", "W", and "Z") that are given specific meanings within the standard
yyyyMMddTHHmmssZ is an ISO8601 format
No it isn't
In your opinion, why is yyyyMMddTHHmmssZ not ISO8601 format?
Per your reference, https://en.wikipedia.org/wiki/ISO_8601, it is (see "Date and time expressed according to ISO 8601" box.
If your statement is due to the missing separators, then per http://www.cl.cam.ac.uk/~mgk25/iso-time.html:
The hyphens can be omitted
...
separating colons can also be omitted
Most helpful comment
In your opinion, why is yyyyMMddTHHmmssZ not ISO8601 format?
Per your reference, https://en.wikipedia.org/wiki/ISO_8601, it is (see "Date and time expressed according to ISO 8601" box.
If your statement is due to the missing separators, then per http://www.cl.cam.ac.uk/~mgk25/iso-time.html: