美文网首页
DateTimeToStr - C++ Builder

DateTimeToStr - C++ Builder

作者: 玄坴 | 来源:发表于2021-10-10 22:03 被阅读0次

    C++ Builder 参考手册System::SysutilsDateTimeToStr


    日期时间类型数值转字符串

    头文件:#include <System.SysUtils.hpp>
    命名空间:System::Sysutils
    函数原型:

    System::UnicodeString __fastcall DateTimeToStr(const System::TDateTime DateTime);
    System::UnicodeString __fastcall DateTimeToStr(const System::TDateTime DateTime, const TFormatSettings &AFormatSettings);
    

    参数:

    • DateTime:日期时间类型变量;
    • AFormatSettings:地区格式;

    返回值:

    • 参数 DateTime 转为字符串;
    • 可以使用全局变量 System::Sysutils::FormatSettings 修改默认的格式;
    • 只有一个 DateTime 参数的 DateTimeToStr 函数不是线程安全的,因为使用了全局变量作为默认的地区格式;带有 AFormatSettings 参数的函数是线程安全的。

    例:

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
        System::TDateTime dt = Sysutils::Now();
        Memo1->Lines->Add(Sysutils::DateTimeToStr(dt));
        Memo1->Lines->Add(Sysutils::DateTimeToStr(dt,TFormatSettings::Create(L"en_US")));
    }
    

    运行结果:

    运行结果

    相关:

    • System::Sysutils::FormatSettings
    • System::Sysutils::TFormatSettings
    • System::Sysutils::StrToBool
    • System::Sysutils::StrToBoolDef
    • System::Sysutils::TryStrToBool
    • System::Sysutils::BoolToStr
    • System::Sysutils::CurrToStr
    • System::Sysutils::CurrToStrF
    • System::Sysutils::DateTimeToStr
    • System::Sysutils::DateTimeToString
    • System::Sysutils::DateToStr
    • System::Sysutils::FloatToStr
    • System::Sysutils::FloatToStrF
    • System::Sysutils::GUIDToString
    • System::Sysutils::IntToStr
    • System::Sysutils::IntToHex
    • System::Sysutils::TimeToStr
    • System::Sysutils::UIntToStr
    • System::Sysutils
    • System::Currency
    • System
    • std::itoa, std::_itoa, std::_itot, std::_itow
    • std::ltoa, std::_ltoa, std::_ltot, std::_ltow
    • std::ultoa, std::_ultoa, std::_ultot, std::_ultow
    • std::_i64toa, std::_i64tot, std::_i64tow
    • std::_ui64toa, std::_ui64tot, std::_ui64tow
    • std::ecvt, std::_ecvt
    • std::fcvt, std::_fcvt
    • std::gcvt, std::_gcvt
    • <cstdlib>

    C++ Builder 参考手册System::SysutilsDateTimeToStr

    相关文章

      网友评论

          本文标题:DateTimeToStr - C++ Builder

          本文链接:https://www.haomeiwen.com/subject/papdahtx.html