Delphi函数崩溃 - StrToDateTime

You*_*ter 0 delphi date

谁能为我的问题提供建议.我将日期格式设置为'JUL/12 - 12 15:35',但是当使用StrToDateTime时,则给出EConvertError.

这个包含2 - 日期分隔符的格式怎么办?


使用下一个代码

    function LocaleFormatStrToDateTime(const S: string): TDateTime;
        var
          LFormatSettings: TFormatSettings;
        begin
          LFormatSettings := GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT);
          LFormatSettings.ShortTimeFormat := FormatSettings.ShortTimeFormat;
          LFormatSettings.TimeSeparator := FormatSettings.TimeSeparator;
          Result := StrToDateTime(S, LFormatSettings);
        end;


----------
Run Code Online (Sandbox Code Playgroud)

**

最好的解决方案是使用jvDateUtil.StrToDate*

**

Rod*_*ddy 5

您的格式完全不标准(并且几乎不可理解),因此内置的日期/时间格式化程序无法处理.

您已经设计了自己的格式,因此您需要编写自己的代码来进行转换.这是大自然告诉你不要使用古怪的日期和时间格式的方式!