如何格式化时间 [英] How to format the time
本文介绍了如何格式化时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误:输入字符串格式不正确。
mm_Form.Append(字符串。格式(PU_TIME:+ string.Format({0:HH:mm},item.Forword_Pickup_Time)+ line_terminator));
如果我使用{0:g}但这会显示秒数,我的老板不喜欢它,然后我更改为字符串显示错误
item.Forword_Pickup_Time是时间跨度
解决方案
也许尝试转义字面冒号:{0:HH \:mm}
不,一切似乎都很好。
价值是多少line_terminator
?
为什么不这样做:
string.Format(PU_TIME:{0:HH:mm} {1},item.Forword_Pickup_Time,line_terminator);
哦,等等,你说这是 timespan !错过了。没有HH
格式。使用{0:hh\\:mm}
http://msdn.microsoft.com/en-us/library/ee372287(v=vs.100).aspx [ ^ ]
error: input string was not in a correct format.
mm_Form.Append(string.Format("PU_TIME: " + string.Format("{0:HH:mm}", item.Forword_Pickup_Time) + line_terminator));
if I use {0:g} but this will show the seconds, my boss doesn't like it,then I change to up string show errors
item.Forword_Pickup_Time is timespan
解决方案
Maybe try escaping the literal colon:{0:HH\:mm}
Nope, everything seems fine.
What is the value ofline_terminator
?
And why not simply do:
string.Format("PU_TIME: {0:HH:mm}{1}", item.Forword_Pickup_Time , line_terminator );
Oh, wait, you say it's a timespan ! Missed that. There's noHH
format. Use{0:hh\\:mm}
http://msdn.microsoft.com/en-us/library/ee372287(v=vs.100).aspx[^]
这篇关于如何格式化时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文