System.Globalization.DateTimeFormatInfo Class

Assembly: Mscorlib.dll
Namespace: System.Globalization
Summary
Defines how DateTime values are formatted and displayed, depending on the culture.
C# Syntax:
[Serializable]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
Thread Safety
This type is safe for multithreaded operations.
Remarks
This class contains information, such as date patterns, time patterns, and AM/PM designators.

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

The user might choose to override some of the values associated with the current culture of Windows through Regional and Language Options (or Regional Options or Regional Settings) in Control Panel. 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. If the CultureInfo.UseUserOverride property is set to true, the properties of the CultureInfo.DateTimeFormat instance, the CultureInfo.NumberFormat instance, and the CultureInfo.TextInfo instance are also retrieved from the user settings. If the user settings are incompatible with the culture associated with the CultureInfo (for example, if the selected calendar is not one of the CultureInfo.OptionalCalendars), the results of the methods and the values of the properties are undefined.

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

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

The following table lists the standard format characters for each standard pattern and the associated DateTimeFormatInfo property that can be set to modify the standard pattern. The format characters are case-sensitive; for example, 'g' and 'G' represent slightly different patterns.



Format Character Associated Property / Description Example Format Pattern (en-US)
d DateTimeFormatInfo.ShortDatePattern MM/dd/yyyy
D DateTimeFormatInfo.LongDatePattern dddd, dd MMMM yyyy
f Full date and time (long date and short time) dddd, dd MMMM yyyy HH:mm
F DateTimeFormatInfo.FullDateTimePattern (long date and long time) dddd, dd MMMM yyyy HH:mm:ss
g General (short date and short time) MM/dd/yyyy HH:mm
G General (short date and long time) MM/dd/yyyy HH:mm:ss
m, M DateTimeFormatInfo.MonthDayPattern MMMM dd
r, R DateTimeFormatInfo.RFC1123Pattern ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
s DateTimeFormatInfo.SortableDateTimePattern (based on ISO 8601) using local time yyyy'-'MM'-'dd'T'HH':'mm':'ss
t DateTimeFormatInfo.ShortTimePattern HH:mm
T DateTimeFormatInfo.LongTimePattern HH:mm:ss
u DateTimeFormatInfo.UniversalSortableDateTimePattern using universal time yyyy'-'MM'-'dd HH':'mm':'ss'Z'
U Full date and time (long date and long time) using universal time dddd, dd MMMM yyyy HH:mm:ss
y, Y DateTimeFormatInfo.YearMonthPattern yyyy MMMM

The following table lists the patterns that can be combined to construct custom patterns. The patterns are case-sensitive; for example, "MM" is recognized, but "mm" is not. If the custom pattern contains white-space characters or characters enclosed in single quotation marks, the output string will also contain those characters. Characters not defined as part of a format pattern or as format characters are reproduced literally.



Format Pattern Description
d The day of the month. Single-digit days will not have a leading zero.
dd The day of the month. Single-digit days will have a leading zero.
ddd The abbreviated name of the day of the week, as defined in DateTimeFormatInfo.AbbreviatedDayNames .
dddd The full name of the day of the week, as defined in DateTimeFormatInfo.DayNames .
M The numeric month. Single-digit months will not have a leading zero.
MM The numeric month. Single-digit months will have a leading zero.
MMM The abbreviated name of the month, as defined in DateTimeFormatInfo.AbbreviatedMonthNames .
MMMM The full name of the month, as defined in DateTimeFormatInfo.MonthNames .
y The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero.
yy The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.
yyyy The year in four digits, including the century.
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 The hour in a 12-hour clock. Single-digit hours will not have a leading zero.
hh The hour in a 12-hour clock. Single-digit hours will have a leading zero.
H The hour in a 24-hour clock. Single-digit hours will not have a leading zero.
HH The hour in a 24-hour clock. Single-digit hours will have a leading zero.
m The minute. Single-digit minutes will not have a leading zero.
mm The minute. Single-digit minutes will have a leading zero.
s The second. Single-digit seconds will not have a leading zero.
ss The second. Single-digit seconds will have a leading zero.
f The fraction of a second in single-digit precision. The remaining digits are truncated.
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.
t The first character in the AM/PM designator defined in DateTimeFormatInfo.AMDesignator or DateTimeFormatInfo.PMDesignator .
tt The AM/PM designator defined in DateTimeFormatInfo.AMDesignator or DateTimeFormatInfo.PMDesignator .
z The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8".
zz The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will 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 will have leading zeros. For example, Pacific Standard Time is "-08:00".
: The default time separator defined in DateTimeFormatInfo.TimeSeparator .
/ The default date separator defined in DateTimeFormatInfo.DateSeparator .
% Where is a format pattern if used alone. The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.
\ Where is any character. Displays the character literally. To display the backslash character, use "\\".

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

A DateTimeFormatInfo or a NumberFormatInfo can be created only for the invariant culture or for specific cultures, not for neutral cultures. For more information about the invariant culture, specific cultures, and neutral cultures, see the CultureInfo class.

This class implements the ICloneable interface to enable duplication of DateTimeFormatInfo objects. It also implements IFormatProvider to supply formatting information to applications.

See also:
System.Globalization Namespace | DateTime | Calendar | CultureInfo | MSDN: formattingoverview

System.Globalization.DateTimeFormatInfo Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new writable instance of the DateTimeFormatInfo class that is culture-independent (invariant).
Public Properties
AbbreviatedDayNames Read-write

Gets or sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
AbbreviatedMonthNames Read-write

Gets or sets a one-dimensional array of type String containing the culture-specific abbreviated names of the months.
AMDesignator Read-write

Gets or sets the string designator for hours that are "ante meridiem" (before noon).
Calendar Read-write

Gets or sets the calendar to use for the current culture.
CalendarWeekRule Read-write

Gets or sets a value that specifies which rule is used to determine the first calendar week of the year.
CurrentInfo Read-only

Gets a read-only DateTimeFormatInfo that formats values based on the current culture.
DateSeparator Read-write

Gets or sets the string that separates the components of a date; that is, the year, month, and day.
DayNames Read-write

Gets or sets a one-dimensional array of type String containing the culture-specific full names of the days of the week.
FirstDayOfWeek Read-write

Gets or sets the first day of the week.
FullDateTimePattern Read-write

Gets or sets the format pattern for a long date and long time value, which is associated with the 'F' format character.
InvariantInfo Read-only

Gets the default read-only DateTimeFormatInfo that is culture-independent (invariant).
IsReadOnly Read-only

Gets a value indicating whether the DateTimeFormatInfo is read-only.
LongDatePattern Read-write

Gets or sets the format pattern for a long date value, which is associated with the 'D' format character.
LongTimePattern Read-write

Gets or sets the format pattern for a long time value, which is associated with the 'T' format character.
MonthDayPattern Read-write

Gets or sets the format pattern for a month and day value, which is associated with the 'm' and 'M' format characters.
MonthNames Read-write

Gets or sets a one-dimensional array of type String containing the culture-specific full names of the months.
PMDesignator Read-write

Gets or sets the string designator for hours that are "post meridiem" (after noon).
RFC1123Pattern Read-only

Gets the format pattern for a time value, which is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) 1123 specification and is associated with the 'r' and 'R' format characters.
ShortDatePattern Read-write

Gets or sets the format pattern for a short date value, which is associated with the 'd' format character.
ShortTimePattern Read-write

Gets or sets the format pattern for a short time value, which is associated with the 't' format character.
SortableDateTimePattern Read-only

Gets the format pattern for a sortable date and time value, which is associated with the 's' format character.
TimeSeparator Read-write

Gets or sets the string that separates the components of time; that is, the hour, minutes, and seconds.
UniversalSortableDateTimePattern Read-only

Gets the format pattern for a universal sortable date and time value, which is associated with the 'u' and 'U' format characters.
YearMonthPattern Read-write

Gets or sets the format pattern for a year and month value, which is associated with the 'y' and 'Y' format characters.
Public Methods
Clone Creates a shallow copy of the DateTimeFormatInfo.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetAbbreviatedDayName Returns the culture-specific abbreviated name of the specified day of the week based on the CultureInfo of the current thread.
GetAbbreviatedEraName Returns the string containing the abbreviated name of the specified era, if an abbreviation exists.
GetAbbreviatedMonthName Returns the culture-specific abbreviated name of the specified month based on the CultureInfo of the current thread.
GetAllDateTimePatterns Overloaded:
GetAllDateTimePatterns()

Returns all the standard patterns in which DateTime values can be formatted.
GetAllDateTimePatterns Overloaded:
GetAllDateTimePatterns(char format)

Returns all the standard patterns in which DateTime values can be formatted using the specified format character.
GetDayName Returns the culture-specific full name of the specified day of the week based on the CultureInfo of the current thread.
GetEra Returns the integer representing the specified era.
GetEraName Returns the string containing the name of the specified era.
GetFormat Returns an object of the specified type that provides a DateTime formatting service.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetInstance Returns the DateTimeFormatInfo associated with the specified IFormatProvider.
GetMonthName Returns the culture-specific full name of the specified month based on the CultureInfo of the current thread.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ReadOnly Returns a read-only DateTimeFormatInfo wrapper.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Globalization.DateTimeFormatInfo Member Details

ctor #1
Summary
Initializes a new writable instance of the DateTimeFormatInfo class that is culture-independent (invariant).

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public DateTimeFormatInfo();
Remarks
The properties of this DateTimeFormatInfo can be modified with user-defined patterns.

Return to top


Property: AbbreviatedDayNames (read-write)
Summary
Gets or sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
C# Syntax:
public string[] AbbreviatedDayNames {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
ArgumentException The property is being set to an array that is multidimensional or whose length is not exactly 7.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If setting this property, the array must be one-dimensional and must have exactly seven elements.

If the custom pattern includes the format pattern "ddd", DateTime.ToString displays the value of DateTimeFormatInfo.AbbreviatedDayNames in place of the "ddd" in the format pattern.

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes. If the selected DateTimeFormatInfo.Calendar does not support abbreviated day names, the array contains the full day names.

See also:
DateTimeFormatInfo.DayNames | DateTimeFormatInfo.AbbreviatedMonthNames | DateTimeFormatInfo.GetAbbreviatedDayName

Return to top


Property: AbbreviatedMonthNames (read-write)
Summary
Gets or sets a one-dimensional array of type String containing the culture-specific abbreviated names of the months.
C# Syntax:
public string[] AbbreviatedMonthNames {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
ArgumentException The property is being set to an array that is multidimensional or whose length is not exactly 13.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If setting this property, the array must be one-dimensional and must have exactly 13 elements. Calendar objects accommodate calendars with 13 months.

If the custom pattern includes the format pattern "MMM", DateTime.ToString displays the value of DateTimeFormatInfo.AbbreviatedMonthNames in place of the "MMM" in the format pattern.

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes. If the selected DateTimeFormatInfo.Calendar does not support abbreviated month names, the array contains the full month names.

See also:
DateTimeFormatInfo.AbbreviatedDayNames | DateTimeFormatInfo.MonthNames | DateTimeFormatInfo.GetAbbreviatedMonthName

Return to top


Property: AMDesignator (read-write)
Summary
Gets or sets the string designator for hours that are "ante meridiem" (before noon).
C# Syntax:
public string AMDesignator {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If the custom pattern includes the format pattern "tt" and the time is before noon, DateTime.ToString displays the value of DateTimeFormatInfo.AMDesignator in place of the "tt" in the format pattern. If the custom pattern includes the format pattern "t", only the first character of DateTimeFormatInfo.AMDesignator is displayed.
See also:
DateTimeFormatInfo.PMDesignator

Return to top


Property: Calendar (read-write)
Summary
Gets or sets the calendar to use for the current culture.
C# Syntax:
public Calendar Calendar {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
ArgumentException The property is being set to a Calendar that is not valid for the current culture.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
The DateTimeFormatInfo.Calendar property only accepts calendars that are valid for the current culture of the current thread. The CultureInfo.Calendar property specifies the default calendar for the culture and the CultureInfo.OptionalCalendars property specifies other calendars supported by the culture.

Changing the value of this property affects the following properties as well: DateTimeFormatInfo.MonthNames, DateTimeFormatInfo.AbbreviatedMonthNames, DateTimeFormatInfo.DayNames, DateTimeFormatInfo.AbbreviatedDayNames, DateTimeFormatInfo.CalendarWeekRule, DateTimeFormatInfo.FirstDayOfWeek, DateTimeFormatInfo.FullDateTimePattern, DateTimeFormatInfo.LongDatePattern, DateTimeFormatInfo.ShortDatePattern, DateTimeFormatInfo.YearMonthPattern, and DateTimeFormatInfo.MonthDayPattern.

For example, if the culture of the current thread is Japanese, this property accepts JapaneseCalendar, GregorianCalendarTypes.Localized GregorianCalendar, or GregorianCalendarTypes.USEnglish GregorianCalendar. When the JapaneseCalendar is used, the default long date pattern is "gg y'\x5e74'M'\x6708'd'\x65e5'". When the GregorianCalendarTypes.Localized GregorianCalendar, is used, the default long date pattern is "yyyy'\x5e74'M'\x6708'd'\x65e5'".

See also:
Calendar | GregorianCalendar | HebrewCalendar | HijriCalendar | JapaneseCalendar | JulianCalendar | KoreanCalendar | ThaiBuddhistCalendar

Return to top


Property: CalendarWeekRule (read-write)
Summary
Gets or sets a value that specifies which rule is used to determine the first calendar week of the year.
C# Syntax:
public CalendarWeekRule CalendarWeekRule {get; set;}
Exceptions
Exception Type Condition
ArgumentOutOfRangeException The property is being set to a value that is not a valid CalendarWeekRule value.
Remarks
This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.
See also:
CalendarWeekRule

Return to top


Property: CurrentInfo (read-only)
Summary
Gets a read-only DateTimeFormatInfo that formats values based on the current culture.
C# Syntax:
public static DateTimeFormatInfo CurrentInfo {get;}
See also:
CultureInfo

Return to top


Property: DateSeparator (read-write)
Summary
Gets or sets the string that separates the components of a date; that is, the year, month, and day.
C# Syntax:
public string DateSeparator {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If the custom pattern includes the format pattern "/", DateTime.ToString displays the value of DateTimeFormatInfo.DateSeparator in place of the "/" in the format pattern.
See also:
DateTimeFormatInfo.TimeSeparator

Return to top


Property: DayNames (read-write)
Summary
Gets or sets a one-dimensional array of type String containing the culture-specific full names of the days of the week.
C# Syntax:
public string[] DayNames {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
ArgumentException The property is being set to an array that is multidimensional or whose length is not exactly 7.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If setting this property, the array must be one-dimensional and must have exactly seven elements.

If the custom pattern includes the format pattern "dddd", DateTime.ToString displays the value of DateTimeFormatInfo.DayNames in place of the "dddd" in the format pattern.

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

See also:
DateTimeFormatInfo.AbbreviatedDayNames | DateTimeFormatInfo.MonthNames | DateTimeFormatInfo.GetDayName

Return to top


Property: FirstDayOfWeek (read-write)
Summary
Gets or sets the first day of the week.
C# Syntax:
public DayOfWeek FirstDayOfWeek {get; set;}
Exceptions
Exception Type Condition
ArgumentOutOfRangeException The property is being set to a value that is not a valid DayOfWeek value.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.
See also:
DayOfWeek

Return to top


Property: FullDateTimePattern (read-write)
Summary
Gets or sets the format pattern for a long date and long time value, which is associated with the 'F' format character.
C# Syntax:
public string FullDateTimePattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "dddd, dd MMMM yyyy HH:mm:ss".

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

Return to top


Property: InvariantInfo (read-only)
Summary
Gets the default read-only DateTimeFormatInfo that is culture-independent (invariant).
C# Syntax:
public static DateTimeFormatInfo InvariantInfo {get;}
Remarks
This property does not change regardless of the current culture.

Return to top


Property: IsReadOnly (read-only)
Summary
Gets a value indicating whether the DateTimeFormatInfo is read-only.
C# Syntax:
public bool IsReadOnly {get;}
See also:
DateTimeFormatInfo.ReadOnly

Return to top


Property: LongDatePattern (read-write)
Summary
Gets or sets the format pattern for a long date value, which is associated with the 'D' format character.
C# Syntax:
public string LongDatePattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "dddd, dd MMMM yyyy".

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

Return to top


Property: LongTimePattern (read-write)
Summary
Gets or sets the format pattern for a long time value, which is associated with the 'T' format character.
C# Syntax:
public string LongTimePattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "HH:mm:ss".

Return to top


Property: MonthDayPattern (read-write)
Summary
Gets or sets the format pattern for a month and day value, which is associated with the 'm' and 'M' format characters.
C# Syntax:
public string MonthDayPattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "MMMM dd".

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

Return to top


Property: MonthNames (read-write)
Summary
Gets or sets a one-dimensional array of type String containing the culture-specific full names of the months.
C# Syntax:
public string[] MonthNames {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
ArgumentException The property is being set to an array that is multidimensional or whose length is not exactly 13.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If setting this property, the array must be one-dimensional and must have exactly 13 elements. Calendar objects accommodate calendars with 13 months.

If the custom pattern includes the format pattern "MMMM", DateTime.ToString displays the value of DateTimeFormatInfo.MonthNames in place of the "MMMM" in the format pattern.

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

See also:
DateTimeFormatInfo.DayNames | DateTimeFormatInfo.AbbreviatedMonthNames | DateTimeFormatInfo.GetMonthName

Return to top


Property: PMDesignator (read-write)
Summary
Gets or sets the string designator for hours that are "post meridiem" (after noon).
C# Syntax:
public string PMDesignator {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If the custom pattern includes the format pattern "tt" and the time is after noon, DateTime.ToString displays the value of DateTimeFormatInfo.PMDesignator in place of the "tt" in the format pattern. If the custom pattern includes the format pattern "t", only the first character of DateTimeFormatInfo.PMDesignator is displayed.
See also:
DateTimeFormatInfo.AMDesignator

Return to top


Property: RFC1123Pattern (read-only)
Summary
Gets the format pattern for a time value, which is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) 1123 specification and is associated with the 'r' and 'R' format characters.
C# Syntax:
public string RFC1123Pattern {get;}

Return to top


Property: ShortDatePattern (read-write)
Summary
Gets or sets the format pattern for a short date value, which is associated with the 'd' format character.
C# Syntax:
public string ShortDatePattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "MM/dd/yyyy".

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

Return to top


Property: ShortTimePattern (read-write)
Summary
Gets or sets the format pattern for a short time value, which is associated with the 't' format character.
C# Syntax:
public string ShortTimePattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "HH:mm".

Return to top


Property: SortableDateTimePattern (read-only)
Summary
Gets the format pattern for a sortable date and time value, which is associated with the 's' format character.
C# Syntax:
public string SortableDateTimePattern {get;}
See also:
DateTimeFormatInfo.UniversalSortableDateTimePattern

Return to top


Property: TimeSeparator (read-write)
Summary
Gets or sets the string that separates the components of time; that is, the hour, minutes, and seconds.
C# Syntax:
public string TimeSeparator {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
If the custom pattern includes the format pattern ":", DateTime.ToString displays the value of DateTimeFormatInfo.TimeSeparator in place of the ":" in the format pattern.
See also:
DateTimeFormatInfo.DateSeparator

Return to top


Property: UniversalSortableDateTimePattern (read-only)
Summary
Gets the format pattern for a universal sortable date and time value, which is associated with the 'u' and 'U' format characters.
C# Syntax:
public string UniversalSortableDateTimePattern {get;}
See also:
DateTimeFormatInfo.SortableDateTimePattern

Return to top


Property: YearMonthPattern (read-write)
Summary
Gets or sets the format pattern for a year and month value, which is associated with the 'y' and 'Y' format characters.
C# Syntax:
public string YearMonthPattern {get; set;}
Exceptions
Exception Type Condition
ArgumentNullException The property is being set to null.
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.
Remarks
See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "yyyy MMMM".

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

Return to top


Method: Clone()
Summary
Creates a shallow copy of the DateTimeFormatInfo.
C# Syntax:
public object Clone();
Return Value:
A new DateTimeFormatInfo copied from the original DateTimeFormatInfo.
Implements:
ICloneable.Clone
Remarks
The clone is writable even if the original DateTimeFormatInfo is read-only; therefore, the properties of the clone can be modified with user-defined patterns.

A shallow copy of an object is a copy of the object only. If the object contains references to other objects, the shallow copy does not create copies of the referred objects. It refers to the original objects instead. In contrast, a deep copy of an object creates a copy of the object and a copy of everything directly or indirectly referenced by that object.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~DateTimeFormatInfo();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetAbbreviatedDayName(
   DayOfWeek dayofweek
)
Summary
Returns the culture-specific abbreviated name of the specified day of the week based on the CultureInfo of the current thread.
C# Syntax:
public string GetAbbreviatedDayName(
   DayOfWeek dayofweek
);
Parameters:

dayofweek

A DayOfWeek value.

Return Value:
The culture-specific abbreviated name of the day of the week represented by dayofweek.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException dayofweek is not a valid DayOfWeek value.
Remarks
For the default invariant DateTimeFormatInfo, this method returns a string from the GregorianCalendar:

Return Value
Sunday "Sun"
Monday "Mon"
Tuesday "Tue"
Wednesday "Wed"
Thursday "Thu"
Friday "Fri"
Saturday "Sat"
See also:
CultureInfo | GregorianCalendar | DateTimeFormatInfo.AbbreviatedDayNames | DayOfWeek

Return to top


Method: GetAbbreviatedEraName(
   int era
)
Summary
Returns the string containing the abbreviated name of the specified era, if an abbreviation exists.
C# Syntax:
public string GetAbbreviatedEraName(
   int era
);
Parameters:

era

The integer representing the era.

Return Value:
A string containing the abbreviated name of the specified era, if an abbreviation exists.

-or-

A string containing the full name of the era, if an abbreviation does not exist.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException era does not represent a valid era in the calendar specified in the DateTimeFormatInfo.Calendar property.
Remarks
The era name is the name a calendar uses to refer to a period of time reckoned from a fixed point or event. For example, "A.D." or "C.E." is the current era in the Gregorian calendar.

The valid values for era are listed in the Calendar.Eras property of the appropriate class derived from Calendar. For example: JapaneseCalendar.Eras displays a list of eras that are supported by this implementation.

If the GregorianCalendar is selected in DateTimeFormatInfo.Calendar, DateTimeFormatInfo ignores punctuation in abbreviated era names; that is, "A.D." is equivalent to "AD".

In the JapaneseCalendar, the abbreviated era name is the first character of the full era name; that is, either the single-character case-insensitive Latin alphabet abbreviation or the single-character Kanji abbreviation.

See also:
JapaneseCalendar | TaiwanCalendar

Return to top


Method: GetAbbreviatedMonthName(
   int month
)
Summary
Returns the culture-specific abbreviated name of the specified month based on the CultureInfo of the current thread.
C# Syntax:
public string GetAbbreviatedMonthName(
   int month
);
Parameters:

month

An integer from 1 through 13 representing the name of the month to retrieve.

Return Value:
The culture-specific abbreviated name of the month represented by month.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException month is less than 1 or greater than 13.
Remarks
For the default invariant DateTimeFormatInfo, this method returns a string from the GregorianCalendar:

Return Value
1 "Jan"
2 "Feb"
3 "Mar"
4 "Apr"
5 "May"
6 "Jun"
7 "Jul"
8 "Aug"
9 "Sep"
10 "Oct"
11 "Nov"
12 "Dec"
13 ""

Calendar objects can accommodate calendars with 13 months. For 12-month calendars, the empty string is always returned as the name of the 13th month.

See also:
Calendar | CultureInfo | GregorianCalendar | DateTimeFormatInfo.AbbreviatedMonthNames

Return to top


Overloaded Method: GetAllDateTimePatterns()
Summary
Returns all the standard patterns in which DateTime values can be formatted.
C# Syntax:
public string[] GetAllDateTimePatterns();
Return Value:
An array containing the standard patterns in which DateTime values can be formatted.
Remarks
See the summary page of the DateTimeFormatInfo class for a list of the standard format characters and their associated patterns.
Example
The following code example gets and prints the DateTime patterns for the current calendar.
 using System;
 using System.Globalization;
 public class SamplesDateTimeFormatInfo  {
 
    public static void Main()  {
 
       // Creates a new DateTimeFormatinfo.
       DateTimeFormatInfo myDtfi = new DateTimeFormatInfo();
 
       // Gets and prints all the patterns.
       String[] myPatternsArray = myDtfi.GetAllDateTimePatterns();
       Console.WriteLine( "ALL the patterns:" );
       PrintIndexAndValues( myPatternsArray );
 
       // Gets and prints the pattern(s) associated with some of the format characters.
       myPatternsArray = myDtfi.GetAllDateTimePatterns('d');
       Console.WriteLine( "The patterns for 'd':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('D');
       Console.WriteLine( "The patterns for 'D':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('f');
       Console.WriteLine( "The patterns for 'f':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('F');
       Console.WriteLine( "The patterns for 'F':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('r');
       Console.WriteLine( "The patterns for 'r':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('R');
       Console.WriteLine( "The patterns for 'R':" );
       PrintIndexAndValues( myPatternsArray );
    }
 
    public static void PrintIndexAndValues( String[] myArray )  {
       int i = 0;
       foreach ( String s in myArray )
          Console.WriteLine( "\t[{0}]:\t{1}", i++, s );
       Console.WriteLine();
    }
 }
 /* 
 This code produces the following output.

 ALL the patterns:
         [0]:    MM/dd/yyyy
         [1]:    M/d/yy
         [2]:    MM/dd/yy
         [3]:    M/d/yyyy
         [4]:    yy/MM/dd
         [5]:    yyyy-MM-dd
         [6]:    dd-MMM-yy
         [7]:    dddd, MMMM dd, yyyy
         [8]:    MMMM dd, yyyy
         [9]:    dddd, dd MMMM, yyyy
         [10]:   dd MMMM, yyyy
         [11]:   dddd, MMMM dd, yyyy HH:mm
         [12]:   dddd, MMMM dd, yyyy hh:mm tt
         [13]:   dddd, MMMM dd, yyyy H:mm
         [14]:   dddd, MMMM dd, yyyy h:mm tt
         [15]:   MMMM dd, yyyy HH:mm
         [16]:   MMMM dd, yyyy hh:mm tt
         [17]:   MMMM dd, yyyy H:mm
         [18]:   MMMM dd, yyyy h:mm tt
         [19]:   dddd, dd MMMM, yyyy HH:mm
         [20]:   dddd, dd MMMM, yyyy hh:mm tt
         [21]:   dddd, dd MMMM, yyyy H:mm
         [22]:   dddd, dd MMMM, yyyy h:mm tt
         [23]:   dd MMMM, yyyy HH:mm
         [24]:   dd MMMM, yyyy hh:mm tt
         [25]:   dd MMMM, yyyy H:mm
         [26]:   dd MMMM, yyyy h:mm tt
         [27]:   dddd, MMMM dd, yyyy HH:mm:ss
         [28]:   dddd, MMMM dd, yyyy hh:mm:ss tt
         [29]:   dddd, MMMM dd, yyyy H:mm:ss
         [30]:   dddd, MMMM dd, yyyy h:mm:ss tt
         [31]:   MMMM dd, yyyy HH:mm:ss
         [32]:   MMMM dd, yyyy hh:mm:ss tt
         [33]:   MMMM dd, yyyy H:mm:ss
         [34]:   MMMM dd, yyyy h:mm:ss tt
         [35]:   dddd, dd MMMM, yyyy HH:mm:ss
         [36]:   dddd, dd MMMM, yyyy hh:mm:ss tt
         [37]:   dddd, dd MMMM, yyyy H:mm:ss
         [38]:   dddd, dd MMMM, yyyy h:mm:ss tt
         [39]:   dd MMMM, yyyy HH:mm:ss
         [40]:   dd MMMM, yyyy hh:mm:ss tt
         [41]:   dd MMMM, yyyy H:mm:ss
         [42]:   dd MMMM, yyyy h:mm:ss tt
         [43]:   MM/dd/yyyy HH:mm
         [44]:   MM/dd/yyyy hh:mm tt
         [45]:   MM/dd/yyyy H:mm
         [46]:   MM/dd/yyyy h:mm tt
         [47]:   M/d/yy HH:mm
         [48]:   M/d/yy hh:mm tt
         [49]:   M/d/yy H:mm
         [50]:   M/d/yy h:mm tt
         [51]:   MM/dd/yy HH:mm
         [52]:   MM/dd/yy hh:mm tt
         [53]:   MM/dd/yy H:mm
         [54]:   MM/dd/yy h:mm tt
         [55]:   M/d/yyyy HH:mm
         [56]:   M/d/yyyy hh:mm tt
         [57]:   M/d/yyyy H:mm
         [58]:   M/d/yyyy h:mm tt
         [59]:   yy/MM/dd HH:mm
         [60]:   yy/MM/dd hh:mm tt
         [61]:   yy/MM/dd H:mm
         [62]:   yy/MM/dd h:mm tt
         [63]:   yyyy-MM-dd HH:mm
         [64]:   yyyy-MM-dd hh:mm tt
         [65]:   yyyy-MM-dd H:mm
         [66]:   yyyy-MM-dd h:mm tt
         [67]:   dd-MMM-yy HH:mm
         [68]:   dd-MMM-yy hh:mm tt
         [69]:   dd-MMM-yy H:mm
         [70]:   dd-MMM-yy h:mm tt
         [71]:   MM/dd/yyyy HH:mm:ss
         [72]:   MM/dd/yyyy hh:mm:ss tt
         [73]:   MM/dd/yyyy H:mm:ss
         [74]:   MM/dd/yyyy h:mm:ss tt
         [75]:   M/d/yy HH:mm:ss
         [76]:   M/d/yy hh:mm:ss tt
         [77]:   M/d/yy H:mm:ss
         [78]:   M/d/yy h:mm:ss tt
         [79]:   MM/dd/yy HH:mm:ss
         [80]:   MM/dd/yy hh:mm:ss tt
         [81]:   MM/dd/yy H:mm:ss
         [82]:   MM/dd/yy h:mm:ss tt
         [83]:   M/d/yyyy HH:mm:ss
         [84]:   M/d/yyyy hh:mm:ss tt
         [85]:   M/d/yyyy H:mm:ss
         [86]:   M/d/yyyy h:mm:ss tt
         [87]:   yy/MM/dd HH:mm:ss
         [88]:   yy/MM/dd hh:mm:ss tt
         [89]:   yy/MM/dd H:mm:ss
         [90]:   yy/MM/dd h:mm:ss tt
         [91]:   yyyy-MM-dd HH:mm:ss
         [92]:   yyyy-MM-dd hh:mm:ss tt
         [93]:   yyyy-MM-dd H:mm:ss
         [94]:   yyyy-MM-dd h:mm:ss tt
         [95]:   dd-MMM-yy HH:mm:ss
         [96]:   dd-MMM-yy hh:mm:ss tt
         [97]:   dd-MMM-yy H:mm:ss
         [98]:   dd-MMM-yy h:mm:ss tt
         [99]:   MMMM dd
         [100]:  MMMM dd
         [101]:  ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
         [102]:  ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
         [103]:  yyyy-MM-dd HH:mm:ss
         [104]:  HH:mm
         [105]:  hh:mm tt
         [106]:  H:mm
         [107]:  h:mm tt
         [108]:  HH:mm:ss
         [109]:  hh:mm:ss tt
         [110]:  H:mm:ss
         [111]:  h:mm:ss tt
         [112]:  yyyy-MM-dd HH:mm:ss
         [113]:  dddd, MMMM dd, yyyy HH:mm:ss
         [114]:  dddd, MMMM dd, yyyy hh:mm:ss tt
         [115]:  dddd, MMMM dd, yyyy H:mm:ss
         [116]:  dddd, MMMM dd, yyyy h:mm:ss tt
         [117]:  MMMM dd, yyyy HH:mm:ss
         [118]:  MMMM dd, yyyy hh:mm:ss tt
         [119]:  MMMM dd, yyyy H:mm:ss
         [120]:  MMMM dd, yyyy h:mm:ss tt
         [121]:  dddd, dd MMMM, yyyy HH:mm:ss
         [122]:  dddd, dd MMMM, yyyy hh:mm:ss tt
         [123]:  dddd, dd MMMM, yyyy H:mm:ss
         [124]:  dddd, dd MMMM, yyyy h:mm:ss tt
         [125]:  dd MMMM, yyyy HH:mm:ss
         [126]:  dd MMMM, yyyy hh:mm:ss tt
         [127]:  dd MMMM, yyyy H:mm:ss
         [128]:  dd MMMM, yyyy h:mm:ss tt
         [129]:  MMMM, yyyy
         [130]:  MMMM, yyyy
 
 The patterns for 'd':
         [0]:    MM/dd/yyyy
         [1]:    M/d/yy
         [2]:    MM/dd/yy
         [3]:    M/d/yyyy
         [4]:    yy/MM/dd
         [5]:    yyyy-MM-dd
         [6]:    dd-MMM-yy
 
 The patterns for 'D':
         [0]:    dddd, MMMM dd, yyyy
         [1]:    MMMM dd, yyyy
         [2]:    dddd, dd MMMM, yyyy
         [3]:    dd MMMM, yyyy
 
 The patterns for 'f':
         [0]:    dddd, MMMM dd, yyyy HH:mm
         [1]:    dddd, MMMM dd, yyyy hh:mm tt
         [2]:    dddd, MMMM dd, yyyy H:mm
         [3]:    dddd, MMMM dd, yyyy h:mm tt
         [4]:    MMMM dd, yyyy HH:mm
         [5]:    MMMM dd, yyyy hh:mm tt
         [6]:    MMMM dd, yyyy H:mm
         [7]:    MMMM dd, yyyy h:mm tt
         [8]:    dddd, dd MMMM, yyyy HH:mm
         [9]:    dddd, dd MMMM, yyyy hh:mm tt
         [10]:   dddd, dd MMMM, yyyy H:mm
         [11]:   dddd, dd MMMM, yyyy h:mm tt
         [12]:   dd MMMM, yyyy HH:mm
         [13]:   dd MMMM, yyyy hh:mm tt
         [14]:   dd MMMM, yyyy H:mm
         [15]:   dd MMMM, yyyy h:mm tt
 
 The patterns for 'F':
         [0]:    dddd, MMMM dd, yyyy HH:mm:ss
         [1]:    dddd, MMMM dd, yyyy hh:mm:ss tt
         [2]:    dddd, MMMM dd, yyyy H:mm:ss
         [3]:    dddd, MMMM dd, yyyy h:mm:ss tt
         [4]:    MMMM dd, yyyy HH:mm:ss
         [5]:    MMMM dd, yyyy hh:mm:ss tt
         [6]:    MMMM dd, yyyy H:mm:ss
         [7]:    MMMM dd, yyyy h:mm:ss tt
         [8]:    dddd, dd MMMM, yyyy HH:mm:ss
         [9]:    dddd, dd MMMM, yyyy hh:mm:ss tt
         [10]:   dddd, dd MMMM, yyyy H:mm:ss
         [11]:   dddd, dd MMMM, yyyy h:mm:ss tt
         [12]:   dd MMMM, yyyy HH:mm:ss
         [13]:   dd MMMM, yyyy hh:mm:ss tt
         [14]:   dd MMMM, yyyy H:mm:ss
         [15]:   dd MMMM, yyyy h:mm:ss tt
 
 The patterns for 'r':
         [0]:    ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
 
 The patterns for 'R':
         [0]:    ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
 */

    

Return to top


Overloaded Method: GetAllDateTimePatterns(
   char format
)
Summary
Returns all the standard patterns in which DateTime values can be formatted using the specified format character.
C# Syntax:
public string[] GetAllDateTimePatterns(
   char format
);
Parameters:

format

A standard format character.

Return Value:
An array containing the standard patterns in which DateTime values can be formatted using the specified format character.
Exceptions
Exception Type Condition
ArgumentException format is not a valid standard format character.
Remarks
See the summary page of the DateTimeFormatInfo class for a list of the standard format characters and their associated patterns.
Example
The following code example gets and prints the DateTime patterns for the current calendar.
 using System;
 using System.Globalization;
 public class SamplesDateTimeFormatInfo  {
 
    public static void Main()  {
 
       // Creates a new DateTimeFormatinfo.
       DateTimeFormatInfo myDtfi = new DateTimeFormatInfo();
 
       // Gets and prints all the patterns.
       String[] myPatternsArray = myDtfi.GetAllDateTimePatterns();
       Console.WriteLine( "ALL the patterns:" );
       PrintIndexAndValues( myPatternsArray );
 
       // Gets and prints the pattern(s) associated with some of the format characters.
       myPatternsArray = myDtfi.GetAllDateTimePatterns('d');
       Console.WriteLine( "The patterns for 'd':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('D');
       Console.WriteLine( "The patterns for 'D':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('f');
       Console.WriteLine( "The patterns for 'f':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('F');
       Console.WriteLine( "The patterns for 'F':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('r');
       Console.WriteLine( "The patterns for 'r':" );
       PrintIndexAndValues( myPatternsArray );
 
       myPatternsArray = myDtfi.GetAllDateTimePatterns('R');
       Console.WriteLine( "The patterns for 'R':" );
       PrintIndexAndValues( myPatternsArray );
    }
 
    public static void PrintIndexAndValues( String[] myArray )  {
       int i = 0;
       foreach ( String s in myArray )
          Console.WriteLine( "\t[{0}]:\t{1}", i++, s );
       Console.WriteLine();
    }
 }
 /* 
 This code produces the following output.

 ALL the patterns:
         [0]:    MM/dd/yyyy
         [1]:    M/d/yy
         [2]:    MM/dd/yy
         [3]:    M/d/yyyy
         [4]:    yy/MM/dd
         [5]:    yyyy-MM-dd
         [6]:    dd-MMM-yy
         [7]:    dddd, MMMM dd, yyyy
         [8]:    MMMM dd, yyyy
         [9]:    dddd, dd MMMM, yyyy
         [10]:   dd MMMM, yyyy
         [11]:   dddd, MMMM dd, yyyy HH:mm
         [12]:   dddd, MMMM dd, yyyy hh:mm tt
         [13]:   dddd, MMMM dd, yyyy H:mm
         [14]:   dddd, MMMM dd, yyyy h:mm tt
         [15]:   MMMM dd, yyyy HH:mm
         [16]:   MMMM dd, yyyy hh:mm tt
         [17]:   MMMM dd, yyyy H:mm
         [18]:   MMMM dd, yyyy h:mm tt
         [19]:   dddd, dd MMMM, yyyy HH:mm
         [20]:   dddd, dd MMMM, yyyy hh:mm tt
         [21]:   dddd, dd MMMM, yyyy H:mm
         [22]:   dddd, dd MMMM, yyyy h:mm tt
         [23]:   dd MMMM, yyyy HH:mm
         [24]:   dd MMMM, yyyy hh:mm tt
         [25]:   dd MMMM, yyyy H:mm
         [26]:   dd MMMM, yyyy h:mm tt
         [27]:   dddd, MMMM dd, yyyy HH:mm:ss
         [28]:   dddd, MMMM dd, yyyy hh:mm:ss tt
         [29]:   dddd, MMMM dd, yyyy H:mm:ss
         [30]:   dddd, MMMM dd, yyyy h:mm:ss tt
         [31]:   MMMM dd, yyyy HH:mm:ss
         [32]:   MMMM dd, yyyy hh:mm:ss tt
         [33]:   MMMM dd, yyyy H:mm:ss
         [34]:   MMMM dd, yyyy h:mm:ss tt
         [35]:   dddd, dd MMMM, yyyy HH:mm:ss
         [36]:   dddd, dd MMMM, yyyy hh:mm:ss tt
         [37]:   dddd, dd MMMM, yyyy H:mm:ss
         [38]:   dddd, dd MMMM, yyyy h:mm:ss tt
         [39]:   dd MMMM, yyyy HH:mm:ss
         [40]:   dd MMMM, yyyy hh:mm:ss tt
         [41]:   dd MMMM, yyyy H:mm:ss
         [42]:   dd MMMM, yyyy h:mm:ss tt
         [43]:   MM/dd/yyyy HH:mm
         [44]:   MM/dd/yyyy hh:mm tt
         [45]:   MM/dd/yyyy H:mm
         [46]:   MM/dd/yyyy h:mm tt
         [47]:   M/d/yy HH:mm
         [48]:   M/d/yy hh:mm tt
         [49]:   M/d/yy H:mm
         [50]:   M/d/yy h:mm tt
         [51]:   MM/dd/yy HH:mm
         [52]:   MM/dd/yy hh:mm tt
         [53]:   MM/dd/yy H:mm
         [54]:   MM/dd/yy h:mm tt
         [55]:   M/d/yyyy HH:mm
         [56]:   M/d/yyyy hh:mm tt
         [57]:   M/d/yyyy H:mm
         [58]:   M/d/yyyy h:mm tt
         [59]:   yy/MM/dd HH:mm
         [60]:   yy/MM/dd hh:mm tt
         [61]:   yy/MM/dd H:mm
         [62]:   yy/MM/dd h:mm tt
         [63]:   yyyy-MM-dd HH:mm
         [64]:   yyyy-MM-dd hh:mm tt
         [65]:   yyyy-MM-dd H:mm
         [66]:   yyyy-MM-dd h:mm tt
         [67]:   dd-MMM-yy HH:mm
         [68]:   dd-MMM-yy hh:mm tt
         [69]:   dd-MMM-yy H:mm
         [70]:   dd-MMM-yy h:mm tt
         [71]:   MM/dd/yyyy HH:mm:ss
         [72]:   MM/dd/yyyy hh:mm:ss tt
         [73]:   MM/dd/yyyy H:mm:ss
         [74]:   MM/dd/yyyy h:mm:ss tt
         [75]:   M/d/yy HH:mm:ss
         [76]:   M/d/yy hh:mm:ss tt
         [77]:   M/d/yy H:mm:ss
         [78]:   M/d/yy h:mm:ss tt
         [79]:   MM/dd/yy HH:mm:ss
         [80]:   MM/dd/yy hh:mm:ss tt
         [81]:   MM/dd/yy H:mm:ss
         [82]:   MM/dd/yy h:mm:ss tt
         [83]:   M/d/yyyy HH:mm:ss
         [84]:   M/d/yyyy hh:mm:ss tt
         [85]:   M/d/yyyy H:mm:ss
         [86]:   M/d/yyyy h:mm:ss tt
         [87]:   yy/MM/dd HH:mm:ss
         [88]:   yy/MM/dd hh:mm:ss tt
         [89]:   yy/MM/dd H:mm:ss
         [90]:   yy/MM/dd h:mm:ss tt
         [91]:   yyyy-MM-dd HH:mm:ss
         [92]:   yyyy-MM-dd hh:mm:ss tt
         [93]:   yyyy-MM-dd H:mm:ss
         [94]:   yyyy-MM-dd h:mm:ss tt
         [95]:   dd-MMM-yy HH:mm:ss
         [96]:   dd-MMM-yy hh:mm:ss tt
         [97]:   dd-MMM-yy H:mm:ss
         [98]:   dd-MMM-yy h:mm:ss tt
         [99]:   MMMM dd
         [100]:  MMMM dd
         [101]:  ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
         [102]:  ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
         [103]:  yyyy-MM-dd HH:mm:ss
         [104]:  HH:mm
         [105]:  hh:mm tt
         [106]:  H:mm
         [107]:  h:mm tt
         [108]:  HH:mm:ss
         [109]:  hh:mm:ss tt
         [110]:  H:mm:ss
         [111]:  h:mm:ss tt
         [112]:  yyyy-MM-dd HH:mm:ss
         [113]:  dddd, MMMM dd, yyyy HH:mm:ss
         [114]:  dddd, MMMM dd, yyyy hh:mm:ss tt
         [115]:  dddd, MMMM dd, yyyy H:mm:ss
         [116]:  dddd, MMMM dd, yyyy h:mm:ss tt
         [117]:  MMMM dd, yyyy HH:mm:ss
         [118]:  MMMM dd, yyyy hh:mm:ss tt
         [119]:  MMMM dd, yyyy H:mm:ss
         [120]:  MMMM dd, yyyy h:mm:ss tt
         [121]:  dddd, dd MMMM, yyyy HH:mm:ss
         [122]:  dddd, dd MMMM, yyyy hh:mm:ss tt
         [123]:  dddd, dd MMMM, yyyy H:mm:ss
         [124]:  dddd, dd MMMM, yyyy h:mm:ss tt
         [125]:  dd MMMM, yyyy HH:mm:ss
         [126]:  dd MMMM, yyyy hh:mm:ss tt
         [127]:  dd MMMM, yyyy H:mm:ss
         [128]:  dd MMMM, yyyy h:mm:ss tt
         [129]:  MMMM, yyyy
         [130]:  MMMM, yyyy
 
 The patterns for 'd':
         [0]:    MM/dd/yyyy
         [1]:    M/d/yy
         [2]:    MM/dd/yy
         [3]:    M/d/yyyy
         [4]:    yy/MM/dd
         [5]:    yyyy-MM-dd
         [6]:    dd-MMM-yy
 
 The patterns for 'D':
         [0]:    dddd, MMMM dd, yyyy
         [1]:    MMMM dd, yyyy
         [2]:    dddd, dd MMMM, yyyy
         [3]:    dd MMMM, yyyy
 
 The patterns for 'f':
         [0]:    dddd, MMMM dd, yyyy HH:mm
         [1]:    dddd, MMMM dd, yyyy hh:mm tt
         [2]:    dddd, MMMM dd, yyyy H:mm
         [3]:    dddd, MMMM dd, yyyy h:mm tt
         [4]:    MMMM dd, yyyy HH:mm
         [5]:    MMMM dd, yyyy hh:mm tt
         [6]:    MMMM dd, yyyy H:mm
         [7]:    MMMM dd, yyyy h:mm tt
         [8]:    dddd, dd MMMM, yyyy HH:mm
         [9]:    dddd, dd MMMM, yyyy hh:mm tt
         [10]:   dddd, dd MMMM, yyyy H:mm
         [11]:   dddd, dd MMMM, yyyy h:mm tt
         [12]:   dd MMMM, yyyy HH:mm
         [13]:   dd MMMM, yyyy hh:mm tt
         [14]:   dd MMMM, yyyy H:mm
         [15]:   dd MMMM, yyyy h:mm tt
 
 The patterns for 'F':
         [0]:    dddd, MMMM dd, yyyy HH:mm:ss
         [1]:    dddd, MMMM dd, yyyy hh:mm:ss tt
         [2]:    dddd, MMMM dd, yyyy H:mm:ss
         [3]:    dddd, MMMM dd, yyyy h:mm:ss tt
         [4]:    MMMM dd, yyyy HH:mm:ss
         [5]:    MMMM dd, yyyy hh:mm:ss tt
         [6]:    MMMM dd, yyyy H:mm:ss
         [7]:    MMMM dd, yyyy h:mm:ss tt
         [8]:    dddd, dd MMMM, yyyy HH:mm:ss
         [9]:    dddd, dd MMMM, yyyy hh:mm:ss tt
         [10]:   dddd, dd MMMM, yyyy H:mm:ss
         [11]:   dddd, dd MMMM, yyyy h:mm:ss tt
         [12]:   dd MMMM, yyyy HH:mm:ss
         [13]:   dd MMMM, yyyy hh:mm:ss tt
         [14]:   dd MMMM, yyyy H:mm:ss
         [15]:   dd MMMM, yyyy h:mm:ss tt
 
 The patterns for 'r':
         [0]:    ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
 
 The patterns for 'R':
         [0]:    ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
 */

    

Return to top


Method: GetDayName(
   DayOfWeek dayofweek
)
Summary
Returns the culture-specific full name of the specified day of the week based on the CultureInfo of the current thread.
C# Syntax:
public string GetDayName(
   DayOfWeek dayofweek
);
Parameters:

dayofweek

A DayOfWeek value.

Return Value:
The culture-specific full name of the day of the week represented by dayofweek.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException dayofweek is not a valid DayOfWeek value.
Remarks
For the default invariant DateTimeFormatInfo, this method returns a string from the GregorianCalendar:

Return Value
Sunday "Sunday"
Monday "Monday"
Tuesday "Tuesday"
Wednesday "Wednesday"
Thursday "Thursday"
Friday "Friday"
Saturday "Saturday"
See also:
CultureInfo | GregorianCalendar | DateTimeFormatInfo.DayNames | DayOfWeek

Return to top


Method: GetEra(
   string eraName
)
Summary
Returns the integer representing the specified era.
C# Syntax:
public int GetEra(
   string eraName
);
Parameters:

eraName

The string containing the name of the era.

Return Value:
The integer representing the era, if eraName is valid; otherwise, -1.
Exceptions
Exception Type Condition
ArgumentNullException eraName is null.
Remarks
The era name is the name a calendar uses to refer to a period of time reckoned from a fixed point or event. For example, "A.D." or "C.E." is the current era in the Gregorian calendar.

The comparison with eraName is case-insensitive; for example, "A.D." is equivalent to "a.d.".

If the GregorianCalendar is selected in DateTimeFormatInfo.Calendar, DateTimeFormatInfo ignores punctuation in abbreviated era names; that is, "A.D." is equivalent to "AD".

DateTimeFormatInfo.GetEra compares eraName with the full era name returned by DateTimeFormatInfo.GetEraName and with the abbreviated era name returned by DateTimeFormatInfo.GetAbbreviatedEraName.

See also:
DateTimeFormatInfo.GetEraName | Calendar

Return to top


Method: GetEraName(
   int era
)
Summary
Returns the string containing the name of the specified era.
C# Syntax:
public string GetEraName(
   int era
);
Parameters:

era

The integer representing the era.

Return Value:
A string containing the name of the era.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException era does not represent a valid era in the calendar specified in the DateTimeFormatInfo.Calendar property.
Remarks
The era name is the name a calendar uses to refer to a period of time reckoned from a fixed point or event. For example, "A.D." or "C.E." is the current era in the Gregorian calendar.

The valid values for era are listed in the Calendar.Eras property of the appropriate class derived from Calendar. For example: JapaneseCalendar.Eras displays a list of eras that are supported by this implementation.

See also:
DateTimeFormatInfo.GetEra

Return to top


Method: GetFormat(
   Type formatType
)
Summary
Returns an object of the specified type that provides a DateTime formatting service.
C# Syntax:
public object GetFormat(
   Type formatType
);
Parameters:

formatType

The Type of the required formatting service.

Return Value:
The current DateTimeFormatInfo, if formatType is the same as the type of the current DateTimeFormatInfo; otherwise, null.
Implements:
IFormatProvider.GetFormat
Remarks
The Format(String, IFormatProvider) method supported by the base data types invoke this method when the current DateTimeFormatInfo is passed as the IFormatProvider parameter. This method implements IFormatProvider.GetFormat.
See also:
IFormatProvider | NumberFormatInfo.GetFormat

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetInstance(
   IFormatProvider provider
)
Summary
Returns the DateTimeFormatInfo associated with the specified IFormatProvider.
C# Syntax:
public static DateTimeFormatInfo GetInstance(
   IFormatProvider provider
);
Parameters:

provider

The IFormatProvider that gets the DateTimeFormatInfo.

-or-

null to get DateTimeFormatInfo.CurrentInfo.

The IFormatProvider that gets the DateTimeFormatInfo.

-or-

null to get DateTimeFormatInfo.CurrentInfo.

Return Value:
A DateTimeFormatInfo associated with the specified IFormatProvider.
Remarks
This method uses the IFormatProvider.GetFormat method of formatProvider using DateTimeFormatInfo as the Type parameter. If formatProvider is null or if IFormatProvider.GetFormat returns null, this method returns DateTimeFormatInfo.CurrentInfo.

You can get a DateTimeFormatInfo for a specific culture using one of the following methods:

A DateTimeFormatInfo can be created only for the invariant culture or for specific cultures, not for neutral cultures. For more information about the invariant culture, specific cultures, and neutral cultures, see the CultureInfo class.

See also:
IFormatProvider

Return to top


Method: GetMonthName(
   int month
)
Summary
Returns the culture-specific full name of the specified month based on the CultureInfo of the current thread.
C# Syntax:
public string GetMonthName(
   int month
);
Parameters:

month

An integer from 1 through 13 representing the name of the month to retrieve.

Return Value:
The culture-specific full name of the month represented by month.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException month is less than 1 or greater than 13.
Remarks
For the default invariant DateTimeFormatInfo, this method returns a string from the GregorianCalendar:

Return Value
1 "January"
2 "February"
3 "March"
4 "April"
5 "May"
6 "June"
7 "July"
8 "August"
9 "September"
10 "October"
11 "November"
12 "December"
13 ""

Calendar objects can accommodate calendars with 13 months. For 12-month calendars, the empty string is always returned as the name of the 13th month.

See also:
Calendar | CultureInfo | GregorianCalendar | DateTimeFormatInfo.MonthNames

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ReadOnly(
   DateTimeFormatInfo dtfi
)
Summary
Returns a read-only DateTimeFormatInfo wrapper.
C# Syntax:
public static DateTimeFormatInfo ReadOnly(
   DateTimeFormatInfo dtfi
);
Parameters:

dtfi

The DateTimeFormatInfo to wrap.

Return Value:
A read-only DateTimeFormatInfo wrapper around dtfi.
Exceptions
Exception Type Condition
ArgumentNullException dtfi is null.
Remarks
This wrapper prevents any modifications to dtfi.
See also:
DateTimeFormatInfo.IsReadOnly

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.