Delphi Basics Home  |  Delphi Basics .NET Home  |  System.TimeSpan  |  Parse Method
Parse  
Method  
Converts a string representation of time span into a TimeSpan value
TimeSpan Structure
System NameSpace
CF1.  Function Parse ( Value : String ) : TimeSpan; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Parses the Value string representation of a time span into a TimeSpan value.
 
The syntax of the Value string is as follows :
 
[blanks][-][days.]hours:mins:secs[.frac][blanks]
 
The square brackets indicate optional values.
 
days Up to 10,675,199
hours 0 to 23
mins 0 to 59
secs 0 to 59
frac 1 to 7 decimal places
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.TimeSpan
System.TimeSpan.Parse
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  span : TimeSpan;

begin
  span := System.TimeSpan.Parse('8:30:0');
  Console.WriteLine('span = {0}', span);

  span := System.TimeSpan.Parse('-123.17:45:20.123456');
  Console.WriteLine('span = {0}', span);

  Console.ReadLine;
end.
   span = 08:30:00
   span = -123.17:45:20.1234560
 
© CodeGear 2006 - 2007. All rights reserved.