Reputation: 187
I am pulling data from work item changes in ADO calling
https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{id}/updates?api-version=6.0
Unfortunately I am getting values back that look like
"System11111ChangedDate": {
"oldValue": "2021-09-28T23:59:171111146Z",
"newValue": "2021-09-28T23:59:2411111677Z"
}
and when I take
string dt = "2021-09-28T23:59:2411111677Z";
DateTime.Parse(dt, null, System.Globalization.DateTimeStyles.RoundtripKind);
I get
{"String '2021-09-28T23:59:2411111677Z' was not recognized as a valid DateTime."}
I have been messing around with this for a while and still have yet to get it to work.
Any thoughts on how I can do this conversion?
TIA
Upvotes: 1
Views: 1313
Reputation: 1733
The original format for ISO 8601 is "yyyy-MM-ddTHH:mm:ss.fffffffz"
The string which you have provided is not in a correct format. One (.) dot is missing after seconds ( i.e., 24 in your string).
I have tried using the same given format by adding the extra dot
string dt = "2021-09-28T23:59:24.11111677Z";
DateTime dt1 = DateTime.Parse(dt, null, System.Globalization.DateTimeStyles.RoundtripKind);
Got the below output
9/28/2021 11:59:24 PM
Upvotes: 2