DateTime.ParseExact抛出格式异常 [英] DateTime.ParseExact throwing format exception
本文介绍了DateTime.ParseExact抛出格式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以下格式的日期 hh:mm:ss:ffff dd / MM / yy(例如... 20:58:54:5854 28/07/07),但是当我尝试
I have a date in the following format "hh:mm:ss:ffff dd/MM/yy" (for example..."20:58:54:5854 28/07/07") but when I try to parse that with DateTime.ParseExact it fails with a format exception.
我的确切代码行是...
My exact line of code is...
var time = DateTime.ParseExact(timeString, "hh:mm:ss:ffff dd/MM/yy", CultureInfo.InvariantCulture);
感谢
Ben
Thanks Ben
推荐答案
您要使用 HH
代替 hh
24小时的格式化时间:
You want to use HH
instead of hh
for 24 hour format time:
DateTime time = DateTime.ParseExact(timeString, "HH:mm:ss:ffff dd/MM/yy", CultureInfo.InvariantCulture);
这篇关于DateTime.ParseExact抛出格式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文