DateTimeFormatInfo クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class DateTimeFormatInfo Implements ICloneable, IFormatProvider
[SerializableAttribute] [ComVisibleAttribute(true)] public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
[SerializableAttribute] [ComVisibleAttribute(true)] public ref class DateTimeFormatInfo sealed : ICloneable, IFormatProvider

このクラスは、日付パターン、時刻パターン、AM/PM 指定子などの情報を格納します。
特定のカルチャの DateTimeFormatInfo を作成するには、そのカルチャの CultureInfo を作成し、CultureInfo.DateTimeFormat プロパティを取得します。現在のスレッドのカルチャに対して DateTimeFormatInfo を作成するには、CurrentInfo プロパティを使用します。インバリアント カルチャの DateTimeFormatInfo を作成するには、読み取り専用バージョンでは InvariantInfo プロパティを使用し、書き込み可能バージョンでは DateTimeFormatInfo コンストラクタを使用します。ニュートラル カルチャの DateTimeFormatInfo は作成できません。
ユーザーは、[コントロール パネル] の [地域と言語のオプション] (オペレーティング システムによっては [地域のオプション] または [地域]) を使用して、Windows の現在のカルチャに関連付けられた値の一部をオーバーライドすることもできます。たとえば、ユーザーが別の形式で日付を表示したり、カルチャの既定の通貨以外の通貨を使用したりすることを選択する場合があります。CultureInfo.UseUserOverride プロパティが true に設定されている場合は、CultureInfo.DateTimeFormat、CultureInfo.NumberFormat、CultureInfo.TextInfo の各インスタンスのプロパティもユーザー設定から取得されます。ユーザー設定と CultureInfo に関連付けられたカルチャとの間に互換性がない場合 (たとえば、選択されたカレンダーが OptionalCalendars のいずれかでない場合)、メソッドの結果およびプロパティの値は未定義です。
DateTime 値は、DateTimeFormatInfo のプロパティに格納されている標準パターンまたはカスタム パターンを使用して、形式指定します。
標準パターンは、書き込み可能 DateTimeFormatInfo に関連付けられたプロパティを設定して、カスタム パターンに置き換えることができます。DateTimeFormatInfo が書き込み可能かどうかを判断するには、IsReadOnly プロパティを使用します。
各標準パターンの標準形式指定文字と、設定して標準パターンを変更できる関連付けられた DateTimeFormatInfo プロパティを次の表に示します。形式指定文字では大文字と小文字が区別されます。たとえば、"g" と "G" は少し異なるパターンを表します。
d | ShortDatePattern |
D | LongDatePattern |
f | |
F | |
g | |
G | |
m, M | MonthDayPattern |
r, R | RFC1123Pattern |
s | |
t | ShortTimePattern |
T | LongTimePattern |
u | |
U | |
y, Y | YearMonthPattern |
カスタム パターンを構築するために組み合わせることができるパターンを次の表に示します。パターンでは大文字と小文字が区別されます。たとえば、"MM" は認識されますが、"mm" は認識されません。カスタム パターンに空白文字または単一引用符で囲まれた文字が含まれる場合は、出力される文字列にもこれらの文字が含まれます。形式パターンの一部または形式指定文字として定義されていない文字は、そのまま出力されます。
d または %d | その月の日付。1 桁の日付で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%d" を指定します。 |
dd | |
dddd | |
M または %M | 月を表す数値。1 桁の月で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%M" を指定します。 |
AbbreviatedMonthNames の定義に基づく、月の省略名。 | |
MMMM | MonthNames の定義に基づく、月の完全名。 |
y または %y | 世紀を指定しない年。世紀を指定しない年が 10 未満の場合、その年は先行ゼロを付けずに表示されます。形式パターンが他の形式パターンと組み合わされていない場合は、"%y" を指定します。 |
時期または時代 (年号)。形式指定される日付に、関連付けられた時期または時代 (年号) の文字列がない場合、このパターンは無視されます。 | |
h または %h | 12 時間形式の時間。1 桁の時刻で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%h" を指定します。 |
H または %H | 24 時間形式の時間。1 桁の時刻で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%H" を指定します。 |
m または %m | 分。1 桁の分で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%m" を指定します。 |
s または %s | 秒。1 桁の秒で、先行ゼロが付きません。形式パターンが他の形式パターンと組み合わされていない場合は、"%s" を指定します。 |
f または %f | 精度 1 桁の秒の端数。残りの桁は切り捨てられます。形式パターンが他の形式パターンと組み合わされていない場合は、"%f" を指定します。 |
ffff | |
ffffff | |
fffffff | |
F または %F | 秒の端数の最も上位の桁が表示されます。その桁が 0 の場合は、何も表示されません。形式パターンが他の形式パターンと組み合わされていない場合は、"%F" を指定します。 |
秒の端数の上位 2 桁が表示されます。ただし、末尾の 0 は表示されません。2 桁とも 0 の場合は、どちらも表示されません。 | |
秒の端数の上位 3 桁が表示されます。ただし、末尾の 0 は表示されません。3 桁とも 0 の場合は、どの桁も表示されません。 | |
FFFF | 秒の端数の上位 4 桁が表示されます。ただし、末尾の 0 は表示されません。4 桁とも 0 の場合は、どの桁も表示されません。 |
秒の端数の上位 5 桁が表示されます。ただし、末尾の 0 は表示されません。5 桁とも 0 の場合は、どの桁も表示されません。 | |
FFFFFF | 秒の端数の上位 6 桁が表示されます。ただし、末尾の 0 は表示されません。6 桁とも 0 の場合は、どの桁も表示されません。 |
FFFFFFF | 秒の端数の上位 7 桁が表示されます。ただし、末尾の 0 は表示されません。7 桁とも 0 の場合は、どの桁も表示されません。 |
t または %t | AMDesignator または PMDesignator で定義される AM/PM 指定子の最初の文字がある場合、その文字。形式パターンが他の形式パターンと組み合わされていない場合は、"%t" を指定します。 |
z または %z | タイム ゾーン オフセット ("+" または "-" の後ろに時間だけを表記)。1 桁の時刻で、先行ゼロが付きません。たとえば、太平洋標準時では "-8" です。形式パターンが他の形式パターンと組み合わされていない場合は、"%z" を指定します。 |
タイム ゾーン オフセット ("+" または "-" の後ろに時間だけを表記)。1 桁の時刻で、先行ゼロが付きます。たとえば、太平洋標準時では "-08" です。 | |
完全タイム ゾーン オフセット ("+" または "-" の後ろに時間と分を表記)。1 桁の時間と分で、先行ゼロが付きません。たとえば、太平洋標準時では "-08:00" です。 | |
: | |
/ | |
% c | 単独で使用される場合、c は形式パターンです。つまり、形式パターン "d"、"f"、"F"、"h"、"m"、"s"、"t"、"y"、"z"、"H"、または "M" を単独で使用する場合は、それぞれ "%d"、"%f"、"%F"、"%h"、"%m"、"%s"、"%t"、"%y"、"%z"、"%H"、または "%M" を指定します。 |
\ c |
上の 2 番目の表に示した形式パターンだけをカスタム パターンの作成に使用できます。最初の表に示した標準形式指定文字は、カスタム パターンの作成に使用できません。カスタム パターンは、次のように最低 2 文字にします。
-
DateTime.ToString( "d" ) は、DateTime 値を返します。"d" は、標準 Short Date パターンです。
-
DateTime.ToString( "d " ) は、その月の日付と空白文字を返します。"d " はカスタム パターンです。
ニュートラル カルチャを除くインバリアント カルチャまたは特定のカルチャに対してだけ、DateTimeFormatInfo または NumberFormatInfo を作成できます。インバリアント カルチャ、特定のカルチャ、およびニュートラル カルチャの詳細については、CultureInfo クラスのトピックを参照してください。
このクラスは、DateTimeFormatInfo オブジェクトを複製できるようにする ICloneable インターフェイスを実装します。アプリケーションに形式指定情報を提供するために、IFormatProvider も実装します。

形式指定文字を使用して、en-US カルチャ用の異なる形式パターンを出力するコードの例を次に示します。この例は、形式指定文字に関連付けられているプロパティの値も表示します。
Imports System Imports System.Globalization Imports Microsoft.VisualBasic Public Class SamplesDTFI Public Shared Sub Main() ' Creates and initializes a DateTimeFormatInfo associated with the en-US culture. Dim myDTFI As DateTimeFormatInfo = New CultureInfo("en-US", False).DateTimeFormat ' Creates a DateTime with the Gregorian date January 3, 2002 (year=2002, month=1, day=3). ' The Gregorian calendar is the default calendar for the en-US culture. Dim myDT As New DateTime(2002, 1, 3) ' Displays the format pattern associated with each format character. Console.WriteLine("FORMAT en-US EXAMPLE") Console.WriteLine("CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY") Console.WriteLine() Console.WriteLine(" d {0}", myDT.ToString("d")) Console.WriteLine(" {0} {1}", myDTFI.ShortDatePattern, "(ShortDatePattern)") Console.WriteLine() Console.WriteLine(" D {0}", myDT.ToString("D")) Console.WriteLine(" {0} {1}", myDTFI.LongDatePattern, "(LongDatePattern)") Console.WriteLine() Console.WriteLine(" f {0}", myDT.ToString("f")) Console.WriteLine() Console.WriteLine(" F {0}", myDT.ToString("F")) Console.WriteLine(" {0} {1}", myDTFI.FullDateTimePattern, "(FullDateTimePattern)") Console.WriteLine() Console.WriteLine(" g {0}", myDT.ToString("g")) Console.WriteLine() Console.WriteLine(" G {0}", myDT.ToString("G")) Console.WriteLine() Console.WriteLine(" m {0}", myDT.ToString("m")) Console.WriteLine(" {0} {1}", myDTFI.MonthDayPattern, "(MonthDayPattern)") Console.WriteLine() Console.WriteLine(" M {0}", myDT.ToString("M")) Console.WriteLine(" {0} {1}", myDTFI.MonthDayPattern, "(MonthDayPattern)") Console.WriteLine() Console.WriteLine(" r {0}", myDT.ToString("r")) Console.WriteLine(" {0} {1}", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") Console.WriteLine() Console.WriteLine(" R {0}", myDT.ToString("R")) Console.WriteLine(" {0} {1}", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") Console.WriteLine() Console.WriteLine(" s {0}", myDT.ToString("s")) Console.WriteLine(" {0} {1}", myDTFI.SortableDateTimePattern, "(SortableDateTimePattern)") Console.WriteLine() Console.WriteLine(" t {0}", myDT.ToString("t")) Console.WriteLine(" {0} {1}", myDTFI.ShortTimePattern, "(ShortTimePattern)") Console.WriteLine() Console.WriteLine(" T {0}", myDT.ToString("T")) Console.WriteLine(" {0} {1}", myDTFI.LongTimePattern, "(LongTimePattern)") Console.WriteLine() Console.WriteLine(" u {0}", myDT.ToString("u")) Console.WriteLine(" {0} {1}", myDTFI.UniversalSortableDateTimePattern, "(UniversalSortableDateTimePattern)") Console.WriteLine() Console.WriteLine(" U {0}", myDT.ToString("U")) Console.WriteLine() Console.WriteLine(" y {0}", myDT.ToString("y")) Console.WriteLine(" {0} {1}", myDTFI.YearMonthPattern, "(YearMonthPattern)") Console.WriteLine() Console.WriteLine(" Y {0}", myDT.ToString("Y")) Console.WriteLine(" {0} {1}", myDTFI.YearMonthPattern, "(YearMonthPattern)") End Sub 'Main End Class 'SamplesDTFI 'This code produces the following output. ' 'FORMAT en-US EXAMPLE 'CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY ' ' d 1/3/2002 ' M/d/yyyy (ShortDatePattern) ' ' D Thursday, January 03, 2002 ' dddd, MMMM dd, yyyy (LongDatePattern) ' ' f Thursday, January 03, 2002 12:00 AM ' ' F Thursday, January 03, 2002 12:00:00 AM ' dddd, MMMM dd, yyyy h:mm:ss tt (FullDateTimePattern) ' ' g 1/3/2002 12:00 AM ' ' G 1/3/2002 12:00:00 AM ' ' m January 03 ' MMMM dd (MonthDayPattern) ' ' M January 03 ' MMMM dd (MonthDayPattern) ' ' r Thu, 03 Jan 2002 00:00:00 GMT ' ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) ' ' R Thu, 03 Jan 2002 00:00:00 GMT ' ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) ' ' s 2002-01-03T00:00:00 ' yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern) ' ' t 12:00 AM ' h:mm tt (ShortTimePattern) ' ' T 12:00:00 AM ' h:mm:ss tt (LongTimePattern) ' ' u 2002-01-03 00:00:00Z ' yyyy'-'MM'-'dd HH':'mm':'ss'Z' (UniversalSortableDateTimePattern) ' ' U Thursday, January 03, 2002 8:00:00 AM ' ' y January, 2002 ' MMMM, yyyy (YearMonthPattern) ' ' Y January, 2002 ' MMMM, yyyy (YearMonthPattern) '
using System; using System.Globalization; public class SamplesDTFI { public static void Main() { // Creates and initializes a DateTimeFormatInfo associated with the en-US culture. DateTimeFormatInfo myDTFI = new CultureInfo( "en-US", false ).DateTimeFormat; // Creates a DateTime with the Gregorian date January 3, 2002 (year=2002, month=1, day=3). // The Gregorian calendar is the default calendar for the en-US culture. DateTime myDT = new DateTime( 2002, 1, 3 ); // Displays the format pattern associated with each format character. Console.WriteLine( "FORMAT en-US EXAMPLE" ); Console.WriteLine( "CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY\n" ); Console.WriteLine( " d {0}", myDT.ToString("d") ); Console.WriteLine( " {0} {1}\n", myDTFI.ShortDatePattern, "(ShortDatePattern)" ); Console.WriteLine( " D {0}", myDT.ToString("D") ); Console.WriteLine( " {0} {1}\n", myDTFI.LongDatePattern, "(LongDatePattern)" ); Console.WriteLine( " f {0}\n", myDT.ToString("f") ); Console.WriteLine( " F {0}", myDT.ToString("F") ); Console.WriteLine( " {0} {1}\n", myDTFI.FullDateTimePattern, "(FullDateTimePattern)" ); Console.WriteLine( " g {0}\n", myDT.ToString("g") ); Console.WriteLine( " G {0}\n", myDT.ToString("G") ); Console.WriteLine( " m {0}", myDT.ToString("m") ); Console.WriteLine( " {0} {1}\n", myDTFI.MonthDayPattern, "(MonthDayPattern)" ); Console.WriteLine( " M {0}", myDT.ToString("M") ); Console.WriteLine( " {0} {1}\n", myDTFI.MonthDayPattern, "(MonthDayPattern)" ); Console.WriteLine( " r {0}", myDT.ToString("r") ); Console.WriteLine( " {0} {1}\n", myDTFI.RFC1123Pattern, "(RFC1123Pattern)" ); Console.WriteLine( " R {0}", myDT.ToString("R") ); Console.WriteLine( " {0} {1}\n", myDTFI.RFC1123Pattern, "(RFC1123Pattern)" ); Console.WriteLine( " s {0}", myDT.ToString("s") ); Console.WriteLine( " {0} {1}\n", myDTFI.SortableDateTimePattern, "(SortableDateTimePattern)" ); Console.WriteLine( " t {0}", myDT.ToString("t") ); Console.WriteLine( " {0} {1}\n", myDTFI.ShortTimePattern, "(ShortTimePattern)" ); Console.WriteLine( " T {0}", myDT.ToString("T") ); Console.WriteLine( " {0} {1}\n", myDTFI.LongTimePattern, "(LongTimePattern)" ); Console.WriteLine( " u {0}", myDT.ToString("u") ); Console.WriteLine( " {0} {1}\n", myDTFI.UniversalSortableDateTimePattern, "(UniversalSortableDateTimePattern)" ); Console.WriteLine( " U {0}\n", myDT.ToString("U") ); Console.WriteLine( " y {0}", myDT.ToString("y") ); Console.WriteLine( " {0} {1}\n", myDTFI.YearMonthPattern, "(YearMonthPattern)" ); Console.WriteLine( " Y {0}", myDT.ToString("Y") ); Console.WriteLine( " {0} {1}\n", myDTFI.YearMonthPattern, "(YearMonthPattern)" ); } } /* This code produces the following output. FORMAT en-US EXAMPLE CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY d 1/3/2002 M/d/yyyy (ShortDatePattern) D Thursday, January 03, 2002 dddd, MMMM dd, yyyy (LongDatePattern) f Thursday, January 03, 2002 12:00 AM F Thursday, January 03, 2002 12:00:00 AM dddd, MMMM dd, yyyy h:mm:ss tt (FullDateTimePattern) g 1/3/2002 12:00 AM G 1/3/2002 12:00:00 AM m January 03 MMMM dd (MonthDayPattern) M January 03 MMMM dd (MonthDayPattern) r Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) R Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) s 2002-01-03T00:00:00 yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern) t 12:00 AM h:mm tt (ShortTimePattern) T 12:00:00 AM h:mm:ss tt (LongTimePattern) u 2002-01-03 00:00:00Z yyyy'-'MM'-'dd HH':'mm':'ss'Z' (UniversalSortableDateTimePattern) U Thursday, January 03, 2002 8:00:00 AM y January, 2002 MMMM, yyyy (YearMonthPattern) Y January, 2002 MMMM, yyyy (YearMonthPattern) */
using namespace System; using namespace System::Globalization; int main() { // Creates and initializes a DateTimeFormatInfo associated with the en-US culture. CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; // Creates a DateTime with the Gregorian date January 3, 2002 (year=2002, month=1, day=3). // The Gregorian calendar is the default calendar for the en-US culture. DateTime myDT = DateTime(2002,1,3); // Displays the format pattern associated with each format character. Console::WriteLine( "FORMAT en-US EXAMPLE" ); Console::WriteLine( "CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY\n" ); Console::WriteLine( " d {0}", myDT.ToString( "d" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->ShortDatePattern, "(ShortDatePattern)" ); Console::WriteLine( " D {0}", myDT.ToString( "D" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->LongDatePattern, "(LongDatePattern)" ); Console::WriteLine( " f {0}\n", myDT.ToString( "f" ) ); Console::WriteLine( " F {0}", myDT.ToString( "F" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->FullDateTimePattern, "(FullDateTimePattern)" ); Console::WriteLine( " g {0}\n", myDT.ToString( "g" ) ); Console::WriteLine( " G {0}\n", myDT.ToString( "G" ) ); Console::WriteLine( " m {0}", myDT.ToString( "m" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->MonthDayPattern, "(MonthDayPattern)" ); Console::WriteLine( " M {0}", myDT.ToString( "M" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->MonthDayPattern, "(MonthDayPattern)" ); Console::WriteLine( " r {0}", myDT.ToString( "r" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->RFC1123Pattern, "(RFC1123Pattern)" ); Console::WriteLine( " R {0}", myDT.ToString( "R" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->RFC1123Pattern, "(RFC1123Pattern)" ); Console::WriteLine( " s {0}", myDT.ToString( "s" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->SortableDateTimePattern, "(SortableDateTimePattern)" ); Console::WriteLine( " t {0}", myDT.ToString( "t" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->ShortTimePattern, "(ShortTimePattern)" ); Console::WriteLine( " T {0}", myDT.ToString( "T" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->LongTimePattern, "(LongTimePattern)" ); Console::WriteLine( " u {0}", myDT.ToString( "u" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->UniversalSortableDateTimePattern, "(UniversalSortableDateTimePattern)" ); Console::WriteLine( " U {0}\n", myDT.ToString( "U" ) ); Console::WriteLine( " y {0}", myDT.ToString( "y" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->YearMonthPattern, "(YearMonthPattern)" ); Console::WriteLine( " Y {0}", myDT.ToString( "Y" ) ); Console::WriteLine( " {0} {1}\n", myDTFI->YearMonthPattern, "(YearMonthPattern)" ); } /* This code produces the following output. FORMAT en-US EXAMPLE CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY d 1/3/2002 M/d/yyyy (ShortDatePattern) D Thursday, January 03, 2002 dddd, MMMM dd, yyyy (LongDatePattern) f Thursday, January 03, 2002 12:00 AM F Thursday, January 03, 2002 12:00:00 AM dddd, MMMM dd, yyyy h:mm:ss tt (FullDateTimePattern) g 1/3/2002 12:00 AM G 1/3/2002 12:00:00 AM m January 03 MMMM dd (MonthDayPattern) M January 03 MMMM dd (MonthDayPattern) r Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) R Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) s 2002-01-03T00:00:00 yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern) t 12:00 AM h:mm tt (ShortTimePattern) T 12:00:00 AM h:mm:ss tt (LongTimePattern) u 2002-01-03 00:00:00Z yyyy'-'MM'-'dd HH':'mm':'ss'Z' (UniversalSortableDateTimePattern) U Thursday, January 03, 2002 8:00:00 AM y January, 2002 MMMM, yyyy (YearMonthPattern) Y January, 2002 MMMM, yyyy (YearMonthPattern) */
import System.* ; import System.Globalization.* ; public class SamplesDTFI { public static void main(String[] args) { // Creates and initializes a DateTimeFormatInfo associated with // the en-US culture. DateTimeFormatInfo myDTFI = (new CultureInfo("en-US", false)).get_DateTimeFormat(); // Creates a DateTime with the Gregorian date January 3, 2002 // (year=2002, month=1, day=3). // The Gregorian calendar is the default calendar for the // en-US culture. DateTime myDT = new DateTime(2002, 1, 3); // Displays the format pattern associated with each format character. Console.WriteLine("FORMAT en-US EXAMPLE"); Console.WriteLine("CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY\n"); Console.WriteLine(" d {0}", myDT.ToString("d")); Console.WriteLine(" {0} {1}\n", myDTFI.get_ShortDatePattern() , "(ShortDatePattern)"); Console.WriteLine(" D {0}", myDT.ToString("D")); Console.WriteLine(" {0} {1}\n", myDTFI.get_LongDatePattern(), "(LongDatePattern)"); Console.WriteLine(" f {0}\n", myDT.ToString("f")); Console.WriteLine(" F {0}", myDT.ToString("F")); Console.WriteLine(" {0} {1}\n", myDTFI.get_FullDateTimePattern() , "(FullDateTimePattern)"); Console.WriteLine(" g {0}\n", myDT.ToString("g")); Console.WriteLine(" G {0}\n", myDT.ToString("G")); Console.WriteLine(" m {0}", myDT.ToString("m")); Console.WriteLine(" {0} {1}\n", myDTFI.get_MonthDayPattern(), "(MonthDayPattern)"); Console.WriteLine(" M {0}", myDT.ToString("M")); Console.WriteLine(" {0} {1}\n", myDTFI.get_MonthDayPattern(), "(MonthDayPattern)"); Console.WriteLine(" r {0}", myDT.ToString("r")); Console.WriteLine(" {0} {1}\n", myDTFI.get_RFC1123Pattern() , "(RFC1123Pattern)"); Console.WriteLine(" R {0}", myDT.ToString("R")); Console.WriteLine(" {0} {1}\n", myDTFI.get_RFC1123Pattern() , "(RFC1123Pattern)"); Console.WriteLine(" s {0}", myDT.ToString("s")); Console.WriteLine(" {0} {1}\n", myDTFI.get_SortableDateTimePattern(), "(SortableDateTimePattern)"); Console.WriteLine(" t {0}", myDT.ToString("t")); Console.WriteLine(" {0} {1}\n", myDTFI.get_ShortTimePattern() , "(ShortTimePattern)"); Console.WriteLine(" T {0}", myDT.ToString("T")); Console.WriteLine(" {0} {1}\n", myDTFI.get_LongTimePattern(), "(LongTimePattern)"); Console.WriteLine(" u {0}", myDT.ToString("u")); Console.WriteLine(" {0} {1}\n", myDTFI.get_UniversalSortableDateTimePattern(), "(UniversalSortableDateTimePattern)"); Console.WriteLine(" U {0}\n", myDT.ToString("U")); Console.WriteLine(" y {0}", myDT.ToString("y")); Console.WriteLine(" {0} {1}\n", myDTFI.get_YearMonthPattern() , "(YearMonthPattern)"); Console.WriteLine(" Y {0}", myDT.ToString("Y")); Console.WriteLine(" {0} {1}\n", myDTFI.get_YearMonthPattern() , "(YearMonthPattern)"); } //main } //SamplesDTFI /* This code produces the following output. FORMAT en-US EXAMPLE CHAR VALUE OF ASSOCIATED PROPERTY, IF ANY d 1/3/2002 M/d/yyyy (ShortDatePattern) D Thursday, January 03, 2002 dddd, MMMM dd, yyyy (LongDatePattern) f Thursday, January 03, 2002 12:00 AM F Thursday, January 03, 2002 12:00:00 AM dddd, MMMM dd, yyyy h:mm:ss tt (FullDateTimePattern) g 1/3/2002 12:00 AM G 1/3/2002 12:00:00 AM m January 03 MMMM dd (MonthDayPattern) M January 03 MMMM dd (MonthDayPattern) r Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) R Thu, 03 Jan 2002 00:00:00 GMT ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (RFC1123Pattern) s 2002-01-03T00:00:00 yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern) t 12:00 AM h:mm tt (ShortTimePattern) T 12:00:00 AM h:mm:ss tt (LongTimePattern) u 2002-01-03 00:00:00Z yyyy'-'MM'-'dd HH':'mm':'ss'Z' (UniversalSortableDateTimePattern) U Thursday, January 03, 2002 8:00:00 AM y January, 2002 MMMM, yyyy (YearMonthPattern) Y January, 2002 MMMM, yyyy (YearMonthPattern) */

System.Globalization.DateTimeFormatInfo


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DateTimeFormatInfo コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DateTimeFormatInfo プロパティ
DateTimeFormatInfo メソッド

名前 | 説明 | |
---|---|---|
![]() | Clone | DateTimeFormatInfo の簡易コピーを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetAbbreviatedDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した曜日のカルチャ固有の省略名を返します。 |
![]() | GetAbbreviatedEraName | 省略形が存在する場合は、指定した時代 (年号) の省略名を格納している文字列を返します。 |
![]() | GetAbbreviatedMonthName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した月のカルチャ固有の省略名を返します。 |
![]() | GetAllDateTimePatterns | オーバーロードされます。 DateTime 値を形式指定できる標準パターンを返します。 |
![]() | GetDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した曜日のカルチャ固有の完全名を返します。 |
![]() | GetEra | 指定した時代 (年号) を表す整数を返します。 |
![]() | GetEraName | 指定した時代 (年号) の名前を格納している文字列を返します。 |
![]() | GetFormat | DateTime 形式指定サービスを提供する指定した型のオブジェクトを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetInstance | 指定した IFormatProvider に関連付けられている DateTimeFormatInfo を返します。 |
![]() | GetMonthName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した月のカルチャ固有の完全名を返します。 |
![]() | GetShortestDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられた、指定した曜日の最も短い省略名を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReadOnly | 読み取り専用 DateTimeFormatInfo ラッパーを返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | SetAllDateTimePatterns | DateTime 値を形式指定できるすべての標準パターンを設定します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

DateTimeFormatInfo メンバ
カルチャに従って、DateTime 値を形式指定および表示する方法を定義します。
DateTimeFormatInfo データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Clone | DateTimeFormatInfo の簡易コピーを作成します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetAbbreviatedDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した曜日のカルチャ固有の省略名を返します。 |
![]() | GetAbbreviatedEraName | 省略形が存在する場合は、指定した時代 (年号) の省略名を格納している文字列を返します。 |
![]() | GetAbbreviatedMonthName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した月のカルチャ固有の省略名を返します。 |
![]() | GetAllDateTimePatterns | オーバーロードされます。 DateTime 値を形式指定できる標準パターンを返します。 |
![]() | GetDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した曜日のカルチャ固有の完全名を返します。 |
![]() | GetEra | 指定した時代 (年号) を表す整数を返します。 |
![]() | GetEraName | 指定した時代 (年号) の名前を格納している文字列を返します。 |
![]() | GetFormat | DateTime 形式指定サービスを提供する指定した型のオブジェクトを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetInstance | 指定した IFormatProvider に関連付けられている DateTimeFormatInfo を返します。 |
![]() | GetMonthName | 現在の DateTimeFormatInfo オブジェクトに関連付けられたカルチャに基づいて、指定した月のカルチャ固有の完全名を返します。 |
![]() | GetShortestDayName | 現在の DateTimeFormatInfo オブジェクトに関連付けられた、指定した曜日の最も短い省略名を取得します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReadOnly | 読み取り専用 DateTimeFormatInfo ラッパーを返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | SetAllDateTimePatterns | DateTime 値を形式指定できるすべての標準パターンを設定します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

- DateTimeFormatInfoのページへのリンク