开发者

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

开发者 https://www.devze.com 2023-01-31 22:57 出处:网络
The following errors with a FormatException: <td class=\"numeric\">@String.Format(\"{0:hh:mm:ss}\", testrun.ExecutionTime)</td>

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

精彩评论

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