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

The following errors with a FormatException exception:

<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 mistake or am I missing something obvious (given the late hour - the last one is probably this).

+4
source share
2 answers

Try to do :

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

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

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

+3
source

Source: https://habr.com/ru/post/1333010/


All Articles