简体   繁体   English

在 Azure DevOps Rest Api 中处理日期

[英]Dealing with dates in Azure DevOps Rest Api

I am pulling data from work item changes in ADO calling我正在从 ADO 调用中的工作项更改中提取数据

https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{id}/updates?api-version=6.0 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."} {“字符串 '2021-09-28T23:59:2411111677Z' 未被识别为有效的日期时间。”}

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 TIA

  • The original format for ISO 8601 is "yyyy-MM-ddTHH:mm:ss.fffffffz" ISO 8601 的原始格式是“yyyy-MM-ddTHH:mm:ss.fffffffz”

  • The string which you have provided is not in a correct format.您提供的字符串格式不正确。 One (.) dot is missing after seconds ( ie, 24 in your string).秒后缺少一个 (.) 点(即字符串中的 24)。

  • 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM