다음을 통해 공유


DateTimeFormatInfo Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines how DateTime values are formatted and displayed, depending on the culture.

Inheritance Hierarchy

System.Object
  System.Globalization.DateTimeFormatInfo

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public NotInheritable Class DateTimeFormatInfo _
    Implements IFormatProvider
[ComVisibleAttribute(true)]
public sealed class DateTimeFormatInfo : IFormatProvider

The DateTimeFormatInfo type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 DateTimeFormatInfo Initializes a new writable instance of the DateTimeFormatInfo class that is culture-independent (invariant).

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 AbbreviatedDayNames Gets or sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 AbbreviatedMonthGenitiveNames Gets or sets a string array of abbreviated month names associated with the current DateTimeFormatInfo object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 AbbreviatedMonthNames Gets or sets a one-dimensional string array that contains the culture-specific abbreviated names of the months.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 AMDesignator Gets or sets the string designator for hours that are "ante meridiem" (before noon).
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 Calendar Gets or sets the calendar to use for the current culture.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 CalendarWeekRule Gets or sets a value that specifies which rule is used to determine the first calendar week of the year.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 CurrentInfo Gets a read-only DateTimeFormatInfo object that represents the date and time formatting information for the current culture.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 DayNames Gets or sets a one-dimensional array of type String containing the culture-specific full names of the days of the week.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 FirstDayOfWeek Gets or sets the first day of the week.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 FullDateTimePattern Gets or sets the custom format string for a long date and long time value, which is associated with the "F" standard date and time format string.
Public propertyStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 InvariantInfo Gets the default read-only DateTimeFormatInfo that is culture-independent (invariant).
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 IsReadOnly Gets a value indicating whether the DateTimeFormatInfo object is read-only.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 LongDatePattern Gets or sets the custom format string for a long date value, which is associated with the "D" standard date and time format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 LongTimePattern Gets or sets the custom format string for a long time value, which is associated with the "T" standard format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 MonthDayPattern Gets or sets the custom format string for a month and day value, which is associated with the "m" and "M" standard date and time format strings.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 MonthGenitiveNames Gets or sets a string array of month names associated with the current DateTimeFormatInfo object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 MonthNames Gets or sets a one-dimensional array of type String containing the culture-specific full names of the months.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 PMDesignator Gets or sets the string designator for hours that are "post meridiem" (after noon).
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 RFC1123Pattern Gets the custom date and time format string that is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) 1123 specification and is associated with the "r" and "R" standard format strings.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 ShortDatePattern Gets or sets the custom date and time format string for a short date value, which is associated with the "d" standard format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 ShortestDayNames Gets or sets a string array of the shortest unique abbreviated day names associated with the current DateTimeFormatInfo object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 ShortTimePattern Gets or sets the custom date and time format string for a short time value, which is associated with the "t" standard format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 SortableDateTimePattern Gets the custom date and time format string for a sortable date and time value, which is associated with the "s" standard format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 UniversalSortableDateTimePattern Gets the custom date and time format string for a universal sortable date and time value, which is associated with the "u" standard format string.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360 YearMonthPattern Gets or sets the custom date and time format string for a year and month value, which is associated with the "y" and "Y" standard format strings.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Clone Creates a shallow copy of the DateTimeFormatInfo object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetAbbreviatedDayName Returns the culture-specific abbreviated name of the specified day of the week based on the culture associated with the current DateTimeFormatInfo object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetAbbreviatedEraName Returns the string containing the abbreviated name of the specified era, if an abbreviation exists.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetAbbreviatedMonthName Returns the culture-specific abbreviated name of the specified month based on the culture associated with the current DateTimeFormatInfo object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetDayName Returns the culture-specific full name of the specified day of the week based on the culture associated with the current DateTimeFormatInfo object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetEra Returns the integer representing the specified era name.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetEraName Returns the string containing the name of the specified era.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetFormat Returns an object of the specified type that provides a DateTime formatting service.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetInstance Returns the DateTimeFormatInfo associated with the specified IFormatProvider.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetMonthName Returns the culture-specific full name of the specified month based on the culture associated with the current DateTimeFormatInfo object.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberSupported by Silverlight for Windows PhoneSupported by Xbox 360 ReadOnly Returns a read-only DateTimeFormatInfo wrapper.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360 ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

This class contains information, such as date patterns, time patterns, and AM/PM designators.

To create a DateTimeFormatInfo object for a specific culture, create a CultureInfo object for that culture and retrieve the CultureInfo.DateTimeFormat property. To create a DateTimeFormatInfo object for the culture of the current thread, use the DateTimeFormatInfo.CurrentInfo property. To create a DateTimeFormatInfo object for the invariant culture, use the DateTimeFormatInfo.InvariantInfo property for a read-only version or the DateTimeFormatInfo constructor for a writable version. It is not possible to create a DateTimeFormatInfo object for a neutral culture.

The user might choose to override some of the values associated with the current system culture. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. The properties of the current culture's DateTimeFormatInfo object reflect these customizations.

DateTime values are formatted using standard or custom patterns stored in the properties of a DateTimeFormatInfo object.

The application can replace standard patterns with custom patterns by setting the associated properties of a writable DateTimeFormatInfo object. To determine if a DateTimeFormatInfo object is writable, use the IsReadOnly property.

The following table lists the standard DateTime format patterns associated with DateTimeFormatInfo properties. For more information, see Standard Date and Time Format Strings.

Format pattern

Associated Property/Description

d

ShortDatePattern

D

LongDatePattern

f

Full date and time (long date and short time)

F

FullDateTimePattern (long date and long time)

g

General (short date and short time)

G

General (short date and long time)

m, M

MonthDayPattern

o, O

Round-trip date/time pattern; with this format pattern, the formatting or parsing operation always uses the invariant culture

r, R

RFC1123Pattern; with this format pattern, the formatting or parsing operation always uses the invariant culture

s

SortableDateTimePattern (based on ISO 8601) using local time; with this format pattern, the formatting or parsing operation always uses the invariant culture

t

ShortTimePattern

T

LongTimePattern

u

UniversalSortableDateTimePattern using the format for universal time display; with this format pattern, the formatting or parsing operation always uses the invariant culture

U

Full date and time (long date and long time) using universal time

y, Y

YearMonthPattern

The following table lists the custom DateTime format patterns and their behavior. For more information, see Custom Date and Time Format Strings.

Format pattern

Description

d, %d

The day of the month. Single-digit days do not have a leading zero. The application specifies "%d" if the format pattern is not combined with other format patterns.

dd

The day of the month. Single-digit days have a leading zero.

ddd

The abbreviated name of the day of the week, as defined in AbbreviatedDayNames.

dddd

The full name of the day of the week, as defined in DayNames.

f, %f

The fraction of a second in single-digit precision. The remaining digits are truncated. The application specifies "%f" if the format pattern is not combined with other format patterns.

ff

The fraction of a second in double-digit precision. The remaining digits are truncated.

fff

The fraction of a second in three-digit precision. The remaining digits are truncated.

ffff

The fraction of a second in four-digit precision. The remaining digits are truncated.

fffff

The fraction of a second in five-digit precision. The remaining digits are truncated.

ffffff

The fraction of a second in six-digit precision. The remaining digits are truncated.

fffffff

The fraction of a second in seven-digit precision. The remaining digits are truncated.

F, %F

Displays the most significant digit of the seconds fraction. Nothing is displayed if the digit is zero. The application specifies "%F" if the format pattern is not combined with other format patterns.

FF

Displays the two most significant digits of the seconds fraction. However, trailing zeros, or two zero digits, are not displayed.

FFF

Displays the three most significant digits of the seconds fraction. However, trailing zeros, or three zero digits, are not displayed.

FFFF

Displays the four most significant digits of the seconds fraction. However, trailing zeros, or four zero digits, are not displayed.

FFFFF

Displays the five most significant digits of the seconds fraction. However, trailing zeros, or five zero digits, are not displayed.

FFFFFF

Displays the six most significant digits of the seconds fraction. However, trailing zeros, or six zero digits, are not displayed.

FFFFFFF

Displays the seven most significant digits of the seconds fraction. However, trailing zeros, or seven zero digits, are not displayed.

gg

The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.

h, %h

The hour in a 12-hour clock. Single-digit hours do not have a leading zero. The application specifies "%h" if the format pattern is not combined with other format patterns.

hh

The hour in a 12-hour clock. Single-digit hours have a leading zero.

H, %H

The hour in a 24-hour clock. Single-digit hours do not have a leading zero. The application specifies "%H" if the format pattern is not combined with other format patterns.

HH

The hour in a 24-hour clock. Single-digit hours have a leading zero.

K

Different values of the Kind property, that is, Local, Utc, or Unspecified.

m, %m

The minute. Single-digit minutes do not have a leading zero. The application specifies "%m" if the format pattern is not combined with other format patterns.

mm

The minute. Single-digit minutes have a leading zero.

M, %M

The numeric month. Single-digit months do not have a leading zero. The application specifies "%M" if the format pattern is not combined with other format patterns.

MM

The numeric month. Single-digit months have a leading zero.

MMM

The abbreviated name of the month, as defined in AbbreviatedMonthNames.

MMMM

The full name of the month, as defined in MonthNames.

s, %s

The second. Single-digit seconds do not have a leading zero. The application specifies "%s" if the format pattern is not combined with other format patterns.

ss

The second. Single-digit seconds have a leading zero.

t, %t

The first character in the AM/PM designator defined in AMDesignator or PMDesignator, if any. The application specifies "%t" if the format pattern is not combined with other format patterns.

tt

The AM/PM designator defined in AMDesignator or PMDesignator, if any. Your application should use this format pattern for languages for which it is necessary to maintain the distinction between AM and PM. An example is Japanese, for which the AM and PM designators differ in the second character instead of the first character.

y, %y

The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero. The application specifies "%y" if the format pattern is not combined with other format patterns.

yy

The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.

yyy

The year in three digits. If the year is less than 100, the year is displayed with a leading zero.

yyyy

The year in four or five digits (depending on the calendar used), including the century. Pads with leading zeros to get four digits. Thai Buddhist and Korean calendars have five-digit years. Users selecting the "yyyy" pattern see all five digits without leading zeros for calendars that have five digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" is selected.

yyyyy

The year in five digits. Pads with leading zeros to get five digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" is selected.

yyyyyy

The year in six digits. Pads with leading zeros to get six digits. Exception: the Japanese and Taiwan calendars always behave as if "yy" is selected. The pattern can be continued with a longer string of "y"s padding with more leading zeros.

z, %z

The time zone offset ("+" or "-" followed by the hour only). Single-digit hours do not have a leading zero. For example, Pacific Standard Time is "-8". The application specifies "%z" if the format pattern is not combined with other format patterns.

zz

The time zone offset ("+" or "-" followed by the hour only). Single-digit hours have a leading zero. For example, Pacific Standard Time is "-08".

zzz

The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes have leading zeros. For example, Pacific Standard Time is "-08:00".

:

The time separator.

/

The date separator.

% c

Where c is a format pattern if used alone. To use format pattern "d", "f", "F", "h", "m", "s", "t", "y", "z", "H", or "M" by itself, the application specifies "%d", "%f", "%F", "%h", "%m", "%s", "%t", "%y", "%z", "%H", or "%M".

The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.

\ c

Where c is any character. Displays the character literally. To display the backslash character, the application should use "\\".

Only format patterns listed in the second table above can be used to create custom patterns. Standard format patterns listed in the first table are used only to create standard patterns. Custom patterns are at least two characters long, for example:

  • DateTime.ToString("d") returns the DateTime value; "d" is the standard short date pattern.

  • DateTime.ToString("%d") returns the day of the month; "%d" is a custom pattern.

  • DateTime.ToString("d ") returns the day of the month followed by a white-space character; "d " is a custom pattern.

This class implements the IFormatProvider interface to supply formatting information to applications.

Examples

The following example prints out the different format patterns for the en-US culture. It also displays the value of the properties associated with the format patterns.

Imports System.Globalization

Public Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Creates and initializes a DateTimeFormatInfo associated with the en-US culture.
      Dim myDTFI As DateTimeFormatInfo = New CultureInfo("en-US").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.
      outputBlock.Text &= "FORMAT  en-US EXAMPLE" & vbCrLf
      outputBlock.Text += String.Format("CHAR    VALUE OF ASSOCIATED PROPERTY, IF ANY") & vbCrLf

      outputBlock.Text += String.Format("  d     {0}", myDT.ToString("d", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.ShortDatePattern, "(ShortDatePattern)") & vbCrLf

      outputBlock.Text += String.Format("  D     {0}", myDT.ToString("D", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.LongDatePattern, "(LongDatePattern)") & vbCrLf

      outputBlock.Text += String.Format("  f     {0}", myDT.ToString("f", myDTFI)) & vbCrLf

      outputBlock.Text += String.Format("  F     {0}", myDT.ToString("F", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.FullDateTimePattern, "(FullDateTimePattern)") & vbCrLf

      outputBlock.Text += String.Format("  g     {0}", myDT.ToString("g", myDTFI)) & vbCrLf

      outputBlock.Text += String.Format("  G     {0}", myDT.ToString("G", myDTFI)) & vbCrLf

      outputBlock.Text += String.Format("  m     {0}", myDT.ToString("m", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.MonthDayPattern, "(MonthDayPattern)") & vbCrLf

      outputBlock.Text += String.Format("  M     {0}", myDT.ToString("M", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.MonthDayPattern, "(MonthDayPattern)") & vbCrLf

      outputBlock.Text += String.Format("  o     {0}", myDT.ToString("o", myDTFI)) & vbCrLf

      outputBlock.Text += String.Format("  r     {0}", myDT.ToString("r", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") & vbCrLf

      outputBlock.Text += String.Format("  R     {0}", myDT.ToString("R", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") & vbCrLf

      outputBlock.Text += String.Format("  s     {0}", myDT.ToString("s", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.SortableDateTimePattern, "(SortableDateTimePattern)") & vbCrLf

      outputBlock.Text += String.Format("  t     {0}", myDT.ToString("t", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.ShortTimePattern, "(ShortTimePattern)") & vbCrLf

      outputBlock.Text += String.Format("  T     {0}", myDT.ToString("T", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.LongTimePattern, "(LongTimePattern)") & vbCrLf

      outputBlock.Text += String.Format("  u     {0}", myDT.ToString("u", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.UniversalSortableDateTimePattern, "(UniversalSortableDateTimePattern)") & vbCrLf

      outputBlock.Text += String.Format("  U     {0}", myDT.ToString("U", myDTFI)) & vbCrLf

      outputBlock.Text += String.Format("  y     {0}", myDT.ToString("y", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.YearMonthPattern, "(YearMonthPattern)") & vbCrLf

      outputBlock.Text += String.Format("  Y     {0}", myDT.ToString("Y", myDTFI)) & vbCrLf
      outputBlock.Text += String.Format("        {0} {1}", myDTFI.YearMonthPattern, "(YearMonthPattern)") & vbCrLf
   End Sub 
End Class
'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)
'  o     2002-01-03T00:00:00.0000000
'  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 Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Creates and initializes a DateTimeFormatInfo associated with the en-US culture.
      DateTimeFormatInfo myDTFI = new CultureInfo("en-US").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.
      outputBlock.Text += "FORMAT  en-US EXAMPLE" + "\n";
      outputBlock.Text += String.Format("CHAR    VALUE OF ASSOCIATED PROPERTY, IF ANY\n") + "\n";
      outputBlock.Text += String.Format("  d     {0}", myDT.ToString("d", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.ShortDatePattern, "(ShortDatePattern)") + "\n";
      outputBlock.Text += String.Format("  D     {0}", myDT.ToString("D", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.LongDatePattern, "(LongDatePattern)") + "\n";
      outputBlock.Text += String.Format("  f     {0}\n", myDT.ToString("f", myDTFI)) + "\n";
      outputBlock.Text += String.Format("  F     {0}", myDT.ToString("F", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.FullDateTimePattern, "(FullDateTimePattern)") + "\n";
      outputBlock.Text += String.Format("  g     {0}\n", myDT.ToString("g", myDTFI)) + "\n";
      outputBlock.Text += String.Format("  G     {0}\n", myDT.ToString("G", myDTFI)) + "\n";
      outputBlock.Text += String.Format("  m     {0}", myDT.ToString("m", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.MonthDayPattern, "(MonthDayPattern)") + "\n";
      outputBlock.Text += String.Format("  M     {0}", myDT.ToString("M", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.MonthDayPattern, "(MonthDayPattern)") + "\n";
      outputBlock.Text += String.Format("  o     {0}\n", myDT.ToString("o", myDTFI)) + "\n";
      outputBlock.Text += String.Format("  r     {0}", myDT.ToString("r", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") + "\n";
      outputBlock.Text += String.Format("  R     {0}", myDT.ToString("R", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.RFC1123Pattern, "(RFC1123Pattern)") + "\n";
      outputBlock.Text += String.Format("  s     {0}", myDT.ToString("s", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.SortableDateTimePattern, "(SortableDateTimePattern)") + "\n";
      outputBlock.Text += String.Format("  t     {0}", myDT.ToString("t", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.ShortTimePattern, "(ShortTimePattern)") + "\n";
      outputBlock.Text += String.Format("  T     {0}", myDT.ToString("T", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.LongTimePattern, "(LongTimePattern)") + "\n";
      outputBlock.Text += String.Format("  u     {0}", myDT.ToString("u", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.UniversalSortableDateTimePattern, "(UniversalSortableDateTimePattern)") + "\n";
      outputBlock.Text += String.Format("  U     {0}\n", myDT.ToString("U", myDTFI)) + "\n";
      outputBlock.Text += String.Format("  y     {0}", myDT.ToString("y", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.YearMonthPattern, "(YearMonthPattern)") + "\n";
      outputBlock.Text += String.Format("  Y     {0}", myDT.ToString("Y", myDTFI)) + "\n";
      outputBlock.Text += String.Format("        {0} {1}\n", myDTFI.YearMonthPattern, "(YearMonthPattern)") + "\n";
   }
}
/*
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)

     o     2002-01-03T00:00:00.0000000

     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)
*/

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.