C++ Builder 參考手冊 ? System::Sysutils ? DateTimeToStr
日期時間類型數(shù)值轉字符串
頭文件:#include <System.SysUtils.hpp>
命名空間:System::Sysutils
函數(shù)原型:
System::UnicodeString __fastcall DateTimeToStr(const System::TDateTime DateTime);
System::UnicodeString __fastcall DateTimeToStr(const System::TDateTime DateTime, const TFormatSettings &AFormatSettings);
參數(shù):
- DateTime:日期時間類型變量呢堰;
- AFormatSettings:地區(qū)格式统屈;
返回值:
- 參數(shù) DateTime 轉為字符串癞谒;
- 可以使用全局變量 System::Sysutils::FormatSettings 修改默認的格式;
- 只有一個 DateTime 參數(shù)的 DateTimeToStr 函數(shù)不是線程安全的,因為使用了全局變量作為默認的地區(qū)格式;帶有 AFormatSettings 參數(shù)的函數(shù)是線程安全的糕档。
例:
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::Sysutils ? DateTimeToStr