TimeSpanStatic: TryParse |
Attempts to parse the string into a TimeSpan object.
Public Function TryParse( ByRef s As String, ByRef Result As TimeSpan ) As Boolean
The TryParse method is like the TimeSpan.Parse(String) method, except that it does not throw an exception if the conversion fails.
The s parameter contains a time interval specification in the form:
[ws][-]{ d | d.hh:mm[:ss[.ff]] | hh:mm[:ss[.ff]] }[ws]
Elements in square brackets ([ and ]) are optional. One selection from the list of alternatives enclosed in braces ({ and }) and separated by vertical bars (|) is required. The following table describes each element.
Element | Description |
---|---|
ws | Optional white space. |
- | An optional minus sign, which indicates a negative TimeSpan. |
d | Days, ranging from 0 to 10675199. |
. | A culture-sensitive symbol that separates days from hours. The invariant format uses a period (".") character. |
hh | Hours, ranging from 0 to 23. |
: | The culture-sensitive time separator symbol. The invariant format uses a colon (":") character. |
mm | Minutes, ranging from 0 to 59. |
ss | Optional seconds, ranging from 0 to 59. |
. | A culture-sensitive symbol that separates seconds from fractions of a second. The invariant format uses a period (".") character. |
ff | Optional fractional seconds, consisting of one to seven decimal digits. |
The components of s must collectively specify a time interval that is greater than or equal to TimeSpan.MinValue and less than or equal to TimeSpan.MaxValue.
The Parse(String) method tries to parse s by using each of the culture-specific formats for the current culture.