DateTimeFormatter.Format 方法

定義

多載

Format(DateTime)

傳回所提供日期和時間的字串表示。

Format(DateTime, String)

傳回字串,表示指定時區中的指定日期和時間,符合格式器目前使用的範本。

Format(DateTime)

傳回所提供日期和時間的字串表示。

public:
 virtual Platform::String ^ Format(DateTime value) = Format;
winrt::hstring Format(DateTime const& value);
public string Format(System.DateTimeOffset value);
function format(value)
Public Function Format (value As DateTimeOffset) As String

參數

value
DateTime DateTimeOffset

要格式化的日期和時間。

傳回

String

Platform::String

winrt::hstring

表示日期和時間的字串。

備註

注意

如果您的應用程式支援日曆,您應該驗證它是否已正確處理 2019 年 5 月日紀元變更。 如需詳細資訊 ,請參閱準備您的應用程式以進行日文紀元變更

另請參閱

適用於

Format(DateTime, String)

傳回字串,表示指定時區中的指定日期和時間,符合格式器目前使用的範本。

public:
 virtual Platform::String ^ Format(DateTime datetime, Platform::String ^ timeZoneId) = Format;
/// [Windows.Foundation.Metadata.Overload("FormatUsingTimeZone")]
winrt::hstring Format(DateTime const& datetime, winrt::hstring const& timeZoneId);
[Windows.Foundation.Metadata.Overload("FormatUsingTimeZone")]
public string Format(System.DateTimeOffset datetime, string timeZoneId);
function format(datetime, timeZoneId)
Public Function Format (datetime As DateTimeOffset, timeZoneId As String) As String

參數

datetime
DateTime DateTimeOffset

要格式化的日期、時間和時區。

timeZoneId
String

Platform::String

winrt::hstring

IANA 時區資料庫的識別碼,識別要用於 (的時區,例如太平洋時間) 的「Americas/Los_Angeles」。

傳回

String

Platform::String

winrt::hstring

表示日期、時間和時區的字串。

屬性

備註

注意

如果您的應用程式支援日曆,您應該驗證它是否已正確處理 2019 年 5 月日紀元變更。 如需詳細資訊 ,請參閱準備您的應用程式以進行日文紀元變更

另請參閱

適用於