ICultureInfo.ParseTime

Syntax

ParseTime(Value: String): DateTime;

Parameters

Value. The value, from which time must be obtained.

Description

The ParseTime method converts the specified string value and gets time component from it.

Comments

Transformation is executed according to the time parameters that are determined in operating system regional standard settings. If transformation is available, the method returns the obtained time in the DateTime format, otherwise exception is thrown.

Due to specific features of system function implementation that determine ParseTime, values containing milliseconds cannot be converted. Also, if 12-hour time format is used: contains AM (before afternoon), or PM (afternoon), and the value itself corresponds to the 24-hour format time (greater than 12), conversion will be correct, and exception will not be thrown. The obtained time will correspond to the afternoon time. Example: the 13.25 AM value will be correctly converted into the date with the time 30.12.1899 13:25:00.

Example

Sub UserProc;
Var
    CI: ICultureInfo;
    d: DateTime;
Begin
    CI := CultureInfo.Current;
    Debug.WriteLine(CI.ParseTime("00:10:10")); //10 min 10 sec
    Debug.WriteLine(CI.ParseTime("11:00:00PM")); //23.00
End Sub UserProc;

After executing the example the development environment console displays two values of time obtained by conversion from string.

See also:

ICultureInfo