C#分析Elasticsearch日期引发异常

xhv8bpkk  于 2022-12-11  发布在  ElasticSearch
关注(0)|答案(1)|浏览(146)

i have extracted a csv file from Elastic(Kibana) and i have a date in format like this:
Dec 6, 2022 @ 23:59:59.000
I'm trying to parse this string:

var date = DateTime.Parse("Dec 6, 2022 @ 23:59:59.000");

but i obtain exception:
String 'Dec 6, 2022 @ 23:59:59.000' was not recognized as a valid DateTime.
How can i parse this type of string in a DateTime? Thank you

sqyvllje

sqyvllje1#

感谢@phuzi使用了DateTime.ParseExact并使用了正确的格式,我成功地解析了日期,下面是代码:

var date = DateTime.ParseExact("Dec 6, 2022 @ 23:59:59.000", "MMM d, yyyy @ HH:mm:ss.fff", CultureInfo.InvariantCulture);

谢谢你

相关问题