ParseDateEx(Value: String; Format: String): DateTime;
Value. Value converted into date type.
Format. Format, according to which the Value value is to be converted.
The ParseDateEx method converts the specified value with determined format into date according to regional standard settings.
The format uses the following codes:
| Code | Description |
| d | Day of month. One-figure day values shown with or without preceding zero. |
| dd | Day of month. One-figure day values that must be shown with preceding zero. |
| ddd | Abbreviated day names as Sun-Mon. |
| dddd | Full weekday names as Sunday-Monday. |
| M | Numeric month view. One-figure month values shown with or without preceding zero. |
| MM | Numeric month view. One-figure month values that must be shown with preceding zero. |
| MMM | Abbreviated month names are used, like Jan - Dec. |
| MMMM | Full month names are used like January - December. |
| y | Two-digit year. One-figure year values shown with or without preceding zero. |
| yy | Two-digit year. One-figure year values that must be shown with preceding zero. |
| yyyy | Four-digit year, including century. |
If the conversion is not possible, the exception is thrown.
Sub ParseDate;
Const
Format = "MMMM: dd-th day yyyy year A. D.";
ParseDate = "January: 21-st day 1981 year A. D.";
Var
c: ICultureInfo;
d, d1, d2: DateTime;
Begin
c := CultureInfo.Current;
d := c.ParseDateEx(ParseDate, Format);
d1 := c.ParseDateEx("21.1.1981", "d.M.yyyy");
d2 := c.ParseDateEx("21.01.1981", "dd.MM.yyyy");
End Sub ParseDate;
After executing the example the "d", "d1", "d2" variables contain the date 21.01.1981 obtained by conversion according to various custom formats.
See also: