次の方法で共有


DateTimeFormatInfo クラス

カルチャに従って、 DateTime 値を形式指定および表示する方法を定義します。

この型のすべてのメンバの一覧については、DateTimeFormatInfo メンバ を参照してください。

System.Object
   System.Globalization.DateTimeFormatInfo

<Serializable>
NotInheritable Public Class DateTimeFormatInfo   Implements ICloneable, IFormatProvider
[C#]
[Serializable]
public sealed class DateTimeFormatInfo : ICloneable,   IFormatProvider
[C++]
[Serializable]
public __gc __sealed class DateTimeFormatInfo : public ICloneable,   IFormatProvider
[JScript]
public
   Serializable
class DateTimeFormatInfo implements ICloneable,   IFormatProvider

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

このクラスは、日付パターン、時刻パターン、AM/PM 指定子などの情報を格納します。

特定のカルチャの DateTimeFormatInfo を作成するには、そのカルチャの CultureInfo を作成し、 CultureInfo.DateTimeFormat プロパティを取得します。現在のスレッドのカルチャに対して DateTimeFormatInfo を作成するには、 CurrentInfo プロパティを使用します。インバリアント カルチャの DateTimeFormatInfo を作成するには、読み取り専用バージョンでは InvariantInfo プロパティを使用し、書き込み可能バージョンでは DateTimeFormatInfo コンストラクタを使用します。ニュートラル カルチャの DateTimeFormatInfo は作成できません。

ユーザーは、[コントロール パネル] の [地域と言語のオプション] (オペレーティング システムによっては [地域のオプション] または [地域]) を使用して、Windows の現在のカルチャに関連付けられた値の一部をオーバーライドすることもできます。たとえば、ユーザーが別の形式で日付を表示したり、カルチャの既定の通貨以外の通貨を使用したりすることを選択する場合があります。 CultureInfo.UseUserOverride プロパティを true に設定した場合は、 CultureInfo.DateTimeFormatCultureInfo.NumberFormatCultureInfo.TextInfo の各インスタンスのプロパティもユーザー設定から取得されます。ユーザー設定と CultureInfo に関連付けられたカルチャとの間に互換性がない場合 (たとえば、選択された暦が OptionalCalendars のいずれかでない場合)、メソッドの結果およびプロパティの値は未定義です。

DateTime 値は、 DateTimeFormatInfo のプロパティに格納されている標準パターンまたはカスタム パターンを使用して、形式指定します。

標準パターンは、書き込み可能 DateTimeFormatInfo に関連付けられたプロパティを設定して、カスタム パターンに置き換えることができます。 DateTimeFormatInfo が書き込み可能かどうかを判断するには、 IsReadOnly プロパティを使用します。

各標準パターンの標準形式指定文字と、設定して標準パターンを変更できる関連付けられた DateTimeFormatInfo プロパティを次の表に示します。形式指定文字では大文字と小文字が区別されます。たとえば、"g" と "G" は少し異なるパターンを表します。

形式指定文字 関連付けられたプロパティ/説明
d ShortDatePattern
D LongDatePattern
f 完全な日付と時刻 (長い日付と短い時刻)。
F FullDateTimePattern (長い日付と長い時刻)。
g 一般 (短い日付と短い時刻)。
G 一般 (短い日付と長い時刻)。
m, M MonthDayPattern
r, R RFC1123Pattern
s 現地時間を使用する SortableDateTimePattern (ISO 8601 準拠)。
t ShortTimePattern
T LongTimePattern
u 世界協定時刻の表示形式を使用する UniversalSortableDateTimePattern
U 世界協定時刻を使用する完全な日付と時刻 (長い日付と長い時刻)。
y, Y YearMonthPattern

カスタム パターンを構築するために組み合わせることができるパターンを次の表に示します。パターンでは大文字と小文字が区別されます。たとえば、"MM" は認識されますが、"mm" は認識されません。カスタム パターンに空白文字または単一引用符で囲まれた文字が含まれる場合は、出力される文字列にもこれらの文字が含まれます。形式パターンの一部または形式指定文字として定義されていない文字は、そのまま出力されます。

形式指定文字列 説明
d その月の日付。1 桁の日付で、先行ゼロが付きません。
dd その月の日付。1 桁の日には、先行ゼロが付きます。
ddd AbbreviatedDayNames の定義に基づく、曜日の省略名。
dddd DayNames の定義に基づく、曜日の完全名。
M 月を表す数値。1 桁の月で、先行ゼロが付きません。
MM 月を表す数値。1 桁の月には、先行ゼロが付きます。
MMM AbbreviatedMonthNames の定義に基づく、月の省略名。
MMMM MonthNames の定義に基づく、月の完全名。
y 世紀を指定しない年。世紀を指定しない年が 10 未満の場合、その年は先行ゼロを付けずに表示されます。
yy 世紀を指定しない年。世紀を指定しない年が 10 未満の場合、その年は先行ゼロを付けて表示されます。
yyyy 世紀を含む 4 桁の年。
gg 時期または時代 (年号)。形式指定される日付に、関連付けられた時期または時代 (年号) の文字列がない場合、このパターンは無視されます。
h 12 時間形式の時間。1 桁の時刻で、先行ゼロが付きません。
hh 12 時間形式の時間。1 桁の時刻で、先行ゼロが付きます。
H 24 時間形式の時間。1 桁の時刻で、先行ゼロが付きません。
HH 24 時間形式の時間。1 桁の時刻で、先行ゼロが付きます。
m 分。1 桁の分で、先行ゼロが付きません。
mm 分。1 桁の分で、先行ゼロが付きます。
s 秒。1 桁の秒で、先行ゼロが付きません。
ss 秒。1 桁の秒には、先行ゼロが付きます。
f 精度 1 桁の秒の端数。残りの桁は切り捨てられます。
ff 精度 2 桁の秒の端数。残りの桁は切り捨てられます。
fff 精度 3 桁の秒の端数。残りの桁は切り捨てられます。
ffff 精度 4 桁の秒の端数。残りの桁は切り捨てられます。
fffff 精度 5 桁の秒の端数。残りの桁は切り捨てられます。
ffffff 精度 6 桁の秒の端数。残りの桁は切り捨てられます。
fffffff 精度 7 桁の秒の端数。残りの桁は切り捨てられます。
t AMDesignator または PMDesignator で定義される AM/PM 指定子の最初の文字がある場合、その文字。
tt AMDesignator または PMDesignator で定義される AM/PM 指定子がある場合、その文字。
z タイム ゾーン オフセット ("+" または "-" の後ろに時間だけを表記)。1 桁の時刻で、先行ゼロが付きません。たとえば、太平洋標準時では "-8" です。
zz タイム ゾーン オフセット ("+" または "-" の後ろに時間だけを表記)。1 桁の時刻で、先行ゼロが付きます。たとえば、太平洋標準時では "-08" です。
zzz 完全タイム ゾーン オフセット ("+" または "-" の後ろに時間と分を表記)。1 桁の時間と分で、先行ゼロが付きません。たとえば、太平洋標準時では "-08:00" です。
: TimeSeparator で定義される既定の時間区切り記号。
/ DateSeparator で定義される既定の日付区切り記号。
% c 単独で使用される場合、 c は形式パターンです。形式パターンがリテラル文字またはその他の形式パターンと組み合わされている場合、"%" 文字は省略できます。
\ c c は任意の文字です。文字をそのまま表示します。バックスラッシュ文字を表示するには、"\\" を使用します。

上の 2 番目の表に示した形式パターンだけをカスタム パターンの作成に使用できます。最初の表に示した標準形式指定文字は、カスタム パターンの作成に使用できません。カスタム パターンは、次のように最低 2 文字にします。

  • DateTime.ToString( "d") は、DateTime 値を返します。"d" は、標準 Short Date パターンです。
  • DateTime.ToString( "%d") は、その月の日付を返します。"%d" はカスタム パターンです。
  • DateTime.ToString( "d ") は、その月の日付と空白文字を返します。"d " はカスタム パターンです。

ニュートラル カルチャを除くインバリアント カルチャまたは特定のカルチャに対してだけ、 DateTimeFormatInfo または NumberFormatInfo を作成できます。インバリアント カルチャ、特定のカルチャ、およびニュートラル カルチャの詳細については、 CultureInfo クラスのトピックを参照してください。

このクラスは、 ICloneable インターフェイスを実装して、 DateTimeFormatInfo オブジェクトの複製ができるようにします。アプリケーションに形式指定情報を提供するために、 IFormatProvider も実装します。

使用例

[Visual Basic, C#, C++] 形式指定文字を使用して、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)
'

[C#] 
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)

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()
{
   // Creates and initializes a DateTimeFormatInfo associated with the en-US culture.
   CultureInfo * MyCI = new CultureInfo(S"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(S"FORMAT  en-US EXAMPLE");
   Console::WriteLine(S"CHAR    VALUE OF ASSOCIATED PROPERTY, IF ANY\n");
   Console::WriteLine(S"  d {0}", myDT.ToString(S"d"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> ShortDatePattern, S"(ShortDatePattern)");
   Console::WriteLine(S"  D {0}", myDT.ToString(S"D"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> LongDatePattern, S"(LongDatePattern)");
   Console::WriteLine(S"  f {0}\n", myDT.ToString(S"f"));
   Console::WriteLine(S"  F {0}", myDT.ToString(S"F"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> FullDateTimePattern, S"(FullDateTimePattern)");
   Console::WriteLine(S"  g {0}\n", myDT.ToString(S"g"));
   Console::WriteLine(S"  G {0}\n", myDT.ToString(S"G"));
   Console::WriteLine(S"  m {0}", myDT.ToString(S"m"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> MonthDayPattern, S"(MonthDayPattern)");
   Console::WriteLine(S"  M {0}", myDT.ToString(S"M"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> MonthDayPattern, S"(MonthDayPattern)");
   Console::WriteLine(S"  r {0}", myDT.ToString(S"r"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> RFC1123Pattern, S"(RFC1123Pattern)");
   Console::WriteLine(S"  R {0}", myDT.ToString(S"R"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> RFC1123Pattern, S"(RFC1123Pattern)");
   Console::WriteLine(S"  s {0}", myDT.ToString(S"s"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> SortableDateTimePattern, S"(SortableDateTimePattern)");
   Console::WriteLine(S"  t {0}", myDT.ToString(S"t"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> ShortTimePattern, S"(ShortTimePattern)");
   Console::WriteLine(S"  T {0}", myDT.ToString(S"T"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> LongTimePattern, S"(LongTimePattern)");
   Console::WriteLine(S"  u {0}", myDT.ToString(S"u"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> UniversalSortableDateTimePattern, S"(UniversalSortableDateTimePattern)");
   Console::WriteLine(S"  U {0}\n", myDT.ToString(S"U"));
   Console::WriteLine(S"  y {0}", myDT.ToString(S"y"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> YearMonthPattern, S"(YearMonthPattern)");
   Console::WriteLine(S"  Y {0}", myDT.ToString(S"Y"));
   Console::WriteLine(S" {0} {1}\n", myDTFI -> YearMonthPattern, S"(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)

*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Globalization

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

アセンブリ: Mscorlib (Mscorlib.dll 内)

参照

DateTimeFormatInfo メンバ | System.Globalization 名前空間 | DateTime | Calendar | CultureInfo | 書式設定の概要