开发者

In ASP.NET MVC RC3 with Razor - @String.Format("{0:hh:mm:ss}", timespan) errors - bug?

The following errors with a FormatException:

<td class="numeric">@String.Format("{0:hh:mm:ss}", testrun.ExecutionTime)</td>

Where ExecutionTime is a TimeSpan. This format string is valid. Is this a bug or am I missing s开发者_运维问答omething obvious (given the late hour - the latter is probably it).


Try escaping the :

String.Format("{0:hh\\:mm\\:ss}", testrun.ExecutionTime)


Aren't you looking for the @testRun.ExecutionTime.ToString("format here") method?

Format strings for timespan: http://msdn.microsoft.com/en-us/library/dd992632.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜