CultureInfo.DateTimeFormat プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As CultureInfo Dim value As DateTimeFormatInfo value = instance.DateTimeFormat instance.DateTimeFormat = value
public: virtual property DateTimeFormatInfo^ DateTimeFormat { DateTimeFormatInfo^ get (); void set (DateTimeFormatInfo^ value); }
/** @property */ public DateTimeFormatInfo get_DateTimeFormat () /** @property */ public void set_DateTimeFormat (DateTimeFormatInfo value)
public function get DateTimeFormat () : DateTimeFormatInfo public function set DateTimeFormat (value : DateTimeFormatInfo)
カルチャに対応する、日時の表示形式を定義する DateTimeFormatInfo。


ニュートラル カルチャを除くインバリアント カルチャまたは特定のカルチャに対してだけ、DateTimeFormatInfo を作成できます。
カルチャは、通常、インバリアント カルチャ、ニュートラル カルチャ、および特定カルチャの 3 つのセットにグループ化されます。
インバリアント カルチャは、カルチャ固有の設定ではありません。空の文字列 ("") を使用した名前で、またはカルチャ識別子 0x007F を使用することによって、インバリアント カルチャを指定できます。InvariantCulture は、インバリアント カルチャのインスタンスを取得します。この設定は、英語と関連付けられていますが、国や地域には関連付けられていません。これは、カルチャを必要とする Globalization 名前空間のほとんどのメソッドで使用できます。
ニュートラル カルチャは、国や地域ではなく、言語に関連付けられているカルチャです。特定のカルチャは、1 つの言語、および 1 つの国または地域に関連付けられたカルチャです。たとえば、"fr" はニュートラル カルチャであり、"fr-FR" は特定のカルチャです。"zh-CHS" (簡体字中国語) および "zh-CHT" (繁体字中国語) はニュートラル カルチャです。
オーバーライドユーザーは、[コントロール パネル] の [地域と言語のオプション] (オペレーティング システムによっては [地域のオプション] または [地域]) を使用して、Windows の現在のカルチャに関連付けられた値の一部をオーバーライドすることもできます。たとえば、ユーザーが別の形式で日付を表示したり、カルチャの既定の通貨以外の通貨を使用したりすることを選択する場合があります。
UseUserOverride が true であり、指定されたカルチャが Windows の現在のカルチャと一致する場合、CultureInfo はこれらのオーバーライド値を使用します。オーバーライド値には、DateTimeFormat プロパティによって返される DateTimeFormatInfo インスタンスのプロパティ、および NumberFormat プロパティによって返される NumberFormatInfo インスタンスのプロパティのユーザー設定値が含まれます。ユーザー設定と CultureInfo に関連付けられたカルチャとの間に互換性がない場合 (たとえば、選択されたカレンダーが OptionalCalendars のいずれかでない場合)、メソッドの結果およびプロパティの値は未定義です。
DateTimeFormat プロパティおよび NumberFormat プロパティの値は、プロパティにアクセスするまで計算されません。アプリケーションの実行中に、[コントロール パネル] を使用して現在のカルチャを新しいカルチャに変更してから、DateTimeFormat プロパティまたは NumberFormat プロパティにアクセスすると、アプリケーションは元のカルチャのオーバーライド値ではなく、新しいカルチャの既定値を取得します。元のカルチャのオーバーライド値を保持するには、現在のカルチャを変更する前に、DateTimeFormat プロパティおよび NumberFormat プロパティにアクセスします。

CultureInfo.Clone が CultureInfo に関連付けられている DateTimeFormatInfo インスタンスと NumberFormatInfo インスタンスのクローンも作成するコードの例を次に示します。
Imports System 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 'Main End Class 'SamplesCultureInfo ' 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 */
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 */
import System.* ; import System.Globalization.* ; public class SamplesCultureInfo { public static void main(String[] args) { // 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.get_DateTimeFormat().set_AMDesignator( "a.m."); myCIclone.get_DateTimeFormat().set_DateSeparator ("-"); myCIclone.get_NumberFormat().set_CurrencySymbol("USD"); myCIclone.get_NumberFormat().set_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.get_DateTimeFormat().get_AMDesignator(), myCIclone.get_DateTimeFormat().get_AMDesignator()); Console.WriteLine("DTFI.DateSeparator\t{0}\t\t{1}", myCI.get_DateTimeFormat().get_DateSeparator(), myCIclone.get_DateTimeFormat().get_DateSeparator()); Console.WriteLine("NFI.CurrencySymbol\t{0}\t\t{1}", myCI.get_NumberFormat().get_CurrencySymbol(), myCIclone.get_NumberFormat().get_CurrencySymbol()); Console.WriteLine("NFI.NumberDecimalDigits\t{0}\t\t{1}", System.Convert.ToString( myCI.get_NumberFormat().get_NumberDecimalDigits()), System.Convert.ToString( myCIclone.get_NumberFormat().get_NumberDecimalDigits())); } //main } //SamplesCultureInfo /* 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 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からCultureInfo.DateTimeFormat プロパティを検索する場合は、下記のリンクをクリックしてください。

- CultureInfo.DateTimeFormat プロパティのページへのリンク