CultureInfo.DateTimeFormat プロパティ
この記事の内容
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
カルチャに対応する、日時の表示形式を定義する DateTimeFormatInfo を取得または設定します。
public:
virtual property System::Globalization::DateTimeFormatInfo ^ DateTimeFormat { System::Globalization::DateTimeFormatInfo ^ get(); void set(System::Globalization::DateTimeFormatInfo ^ value); };
public virtual System.Globalization.DateTimeFormatInfo DateTimeFormat { get; set; }
member this.DateTimeFormat : System.Globalization.DateTimeFormatInfo with get, set
Public Overridable Property DateTimeFormat As DateTimeFormatInfo
カルチャに対応する、日時の表示形式を定義する DateTimeFormatInfo。
プロパティが null に設定されています。
DateTimeFormat プロパティまたは DateTimeFormatInfo プロパティのいずれかが設定され、CultureInfo は読み取り専用です。
次のコード例は、CultureInfo.Clone によって、 に関連付CultureInfoけられている インスタンスと NumberFormatInfo インスタンスも複製DateTimeFormatInfoされることを示しています。
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates and initializes a CultureInfo.
CultureInfo^ myCI = gcnew CultureInfo( "en-US",false );
// Clones myCI and modifies the DTFI and NFI instances associated with the clone.
CultureInfo^ myCIclone = dynamic_cast<CultureInfo^>(myCI->Clone());
myCIclone->DateTimeFormat->AMDesignator = "a.m.";
myCIclone->DateTimeFormat->DateSeparator = "-";
myCIclone->NumberFormat->CurrencySymbol = "USD";
myCIclone->NumberFormat->NumberDecimalDigits = 4;
// Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator, myCIclone->DateTimeFormat->AMDesignator );
Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator, myCIclone->DateTimeFormat->DateSeparator );
Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol, myCIclone->NumberFormat->CurrencySymbol );
Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits, myCIclone->NumberFormat->NumberDecimalDigits );
}
/*
This code produces the following output.
DTFI/NFI PROPERTY ORIGINAL MODIFIED CLONE
DTFI.AMDesignator AM a.m.
DTFI.DateSeparator / -
NFI.CurrencySymbol $ USD
NFI.NumberDecimalDigits 2 4
*/
using System;
using System.Globalization;
public class SamplesCultureInfo {
public static void Main() {
// Creates and initializes a CultureInfo.
CultureInfo myCI = new CultureInfo("en-US", false);
// Clones myCI and modifies the DTFI and NFI instances associated with the clone.
CultureInfo myCIclone = (CultureInfo) myCI.Clone();
myCIclone.DateTimeFormat.AMDesignator = "a.m.";
myCIclone.DateTimeFormat.DateSeparator = "-";
myCIclone.NumberFormat.CurrencySymbol = "USD";
myCIclone.NumberFormat.NumberDecimalDigits = 4;
// Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
Console.WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" );
Console.WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator );
Console.WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator );
Console.WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol );
Console.WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits );
}
}
/*
This code produces the following output.
DTFI/NFI PROPERTY ORIGINAL MODIFIED CLONE
DTFI.AMDesignator AM a.m.
DTFI.DateSeparator / -
NFI.CurrencySymbol $ USD
NFI.NumberDecimalDigits 2 4
*/
Imports System.Globalization
Public Class SamplesCultureInfo
Public Shared Sub Main()
' Creates and initializes a CultureInfo.
Dim myCI As New CultureInfo("en-US", False)
' Clones myCI and modifies the DTFI and NFI instances associated with the clone.
Dim myCIclone As CultureInfo = CType(myCI.Clone(), CultureInfo)
myCIclone.DateTimeFormat.AMDesignator = "a.m."
myCIclone.DateTimeFormat.DateSeparator = "-"
myCIclone.NumberFormat.CurrencySymbol = "USD"
myCIclone.NumberFormat.NumberDecimalDigits = 4
' Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
Console.WriteLine("DTFI/NFI PROPERTY" + ControlChars.Tab + "ORIGINAL" + ControlChars.Tab + "MODIFIED CLONE")
Console.WriteLine("DTFI.AMDesignator" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.DateTimeFormat.AMDesignator, myCIclone.DateTimeFormat.AMDesignator)
Console.WriteLine("DTFI.DateSeparator" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.DateTimeFormat.DateSeparator, myCIclone.DateTimeFormat.DateSeparator)
Console.WriteLine("NFI.CurrencySymbol" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol)
Console.WriteLine("NFI.NumberDecimalDigits" + ControlChars.Tab + "{0}" + ControlChars.Tab + ControlChars.Tab + "{1}", myCI.NumberFormat.NumberDecimalDigits, myCIclone.NumberFormat.NumberDecimalDigits)
End Sub
End Class
' This code produces the following output.
'
' DTFI/NFI PROPERTY ORIGINAL MODIFIED CLONE
' DTFI.AMDesignator AM a.m.
' DTFI.DateSeparator / -
' NFI.CurrencySymbol $ USD
' NFI.NumberDecimalDigits 2 4
windows の現在のカルチャに関連付けられている値の一部を、コントロール パネルの地域と言語のオプションの部分を使用してオーバーライドすることもできます。 たとえば、ユーザーは日付を別の形式で表示するか、カルチャの既定値以外の通貨を使用するかを選択できます。
が true
で、指定したカルチャが Windows の現在のカルチャと一致する場合UseUserOverride、 CultureInfo では、プロパティによって返されるインスタンスのDateTimeFormatInfoプロパティのユーザー設定や、 プロパティによってDateTimeFormat返されるインスタンスのNumberFormatInfoプロパティなど、これらのオーバーライドがNumberFormat使用されます。 ユーザー設定が に関連付けられている CultureInfoカルチャと互換性がない場合 (たとえば、選択した予定表が の OptionalCalendars1 つではない場合)、メソッドの結果とプロパティの値は未定義です。
プロパティと NumberFormat プロパティのDateTimeFormat値は、アプリケーションが プロパティにアクセスするまで計算されません。 アプリケーションの実行中にユーザーが現在のカルチャを新しいカルチャに変更し、アプリケーションが または NumberFormat プロパティにアクセスDateTimeFormatできる場合、アプリケーションは元のカルチャのオーバーライドではなく、新しいカルチャの既定値を取得します。 元の現在のカルチャのオーバーライドを保持するには、現在のカルチャを変更する前に、 プロパティと NumberFormat プロパティにアクセスDateTimeFormatする必要があります。
が ですが、 TaiwanCalendarCurrentCulture が中国語 (台湾) に設定されていない場合Calendarは、zh-TW という名前で 、、NativeCalendarNameGetEraName(Int32)空GetAbbreviatedEraName(Int32)の文字列 ("") が返されます。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。