A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/dotnet/api/system.globalization.datetimeformatinfo below:

DateTimeFormatInfo Class (System.Globalization) | Microsoft Learn

DateTimeFormatInfo Class Definition

Provides culture-specific information about the format of date and time values.

public ref class DateTimeFormatInfo sealed : IFormatProvider
public ref class DateTimeFormatInfo sealed : ICloneable, IFormatProvider
public ref class DateTimeFormatInfo sealed : ICloneable, IFormatProvider, System::Runtime::Serialization::ISerializable
public sealed class DateTimeFormatInfo : IFormatProvider
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
[System.Serializable]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider, System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
type DateTimeFormatInfo = class
    interface IFormatProvider
type DateTimeFormatInfo = class
    interface ICloneable
    interface IFormatProvider
[<System.Serializable>]
type DateTimeFormatInfo = class
    interface ICloneable
    interface IFormatProvider
    interface ISerializable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type DateTimeFormatInfo = class
    interface ICloneable
    interface IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements ICloneable, IFormatProvider
Public NotInheritable Class DateTimeFormatInfo
Implements ICloneable, IFormatProvider, ISerializable
Inheritance
Attributes
Implements
Examples

The following example uses reflection to get the properties of the DateTimeFormatInfo object for the English (United States) culture. It displays the value of those properties that contain custom format strings and uses those strings to display formatted dates.

using System;
using System.Globalization;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      // Get the properties of an en-US DateTimeFormatInfo object.
      DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo("en-US").DateTimeFormat;
      Type typ = dtfi.GetType();
      PropertyInfo[] props = typ.GetProperties();
      DateTime value = new DateTime(2012, 5, 28, 11, 35, 0);

      foreach (var prop in props) {
         // Is this a format pattern-related property?
         if (prop.Name.Contains("Pattern")) {
            string fmt = prop.GetValue(dtfi, null).ToString();
            Console.WriteLine("{0,-33} {1} \n{2,-37}Example: {3}\n",
                              prop.Name + ":", fmt, "",
                              value.ToString(fmt));
         }
      }
   }
}
// The example displays the following output:
//    FullDateTimePattern:              dddd, MMMM dd, yyyy h:mm:ss tt
//                                         Example: Monday, May 28, 2012 11:35:00 AM
//
//    LongDatePattern:                  dddd, MMMM dd, yyyy
//                                         Example: Monday, May 28, 2012
//
//    LongTimePattern:                  h:mm:ss tt
//                                         Example: 11:35:00 AM
//
//    MonthDayPattern:                  MMMM dd
//                                         Example: May 28
//
//    RFC1123Pattern:                   ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
//                                         Example: Mon, 28 May 2012 11:35:00 GMT
//
//    ShortDatePattern:                 M/d/yyyy
//                                         Example: 5/28/2012
//
//    ShortTimePattern:                 h:mm tt
//                                         Example: 11:35 AM
//
//    SortableDateTimePattern:          yyyy'-'MM'-'dd'T'HH':'mm':'ss
//                                         Example: 2012-05-28T11:35:00
//
//    UniversalSortableDateTimePattern: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
//                                         Example: 2012-05-28 11:35:00Z
//
//    YearMonthPattern:                 MMMM, yyyy
//                                         Example: May, 2012
Imports System.Globalization
Imports System.Reflection

Module Example
   Public Sub Main()
      ' Get the properties of an en-US DateTimeFormatInfo object.
      Dim dtfi As DateTimeFormatInfo = CultureInfo.GetCultureInfo("en-US").DateTimeFormat
      Dim typ As Type = dtfi.GetType()
      Dim props() As PropertyInfo = typ.GetProperties()
      Dim value As Date = #05/28/2012 11:35AM# 
      
      For Each prop In props
         ' Is this a format pattern-related property?
         If prop.Name.Contains("Pattern") Then
            Dim fmt As String = CStr(prop.GetValue(dtfi, Nothing))
            Console.WriteLine("{0,-33} {1} {2}{3,-37}Example: {4}", 
                              prop.Name + ":", fmt, vbCrLf, "",
                              value.ToString(fmt)) 
            Console.WriteLine()
         End If
      Next
   End Sub
End Module
' The example displays the following output:
'    FullDateTimePattern:              dddd, MMMM dd, yyyy h:mm:ss tt
'                                         Example: Monday, May 28, 2012 11:35:00 AM
'    
'    LongDatePattern:                  dddd, MMMM dd, yyyy
'                                         Example: Monday, May 28, 2012
'    
'    LongTimePattern:                  h:mm:ss tt
'                                         Example: 11:35:00 AM
'    
'    MonthDayPattern:                  MMMM dd
'                                         Example: May 28
'    
'    RFC1123Pattern:                   ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
'                                         Example: Mon, 28 May 2012 11:35:00 GMT
'    
'    ShortDatePattern:                 M/d/yyyy
'                                         Example: 5/28/2012
'    
'    ShortTimePattern:                 h:mm tt
'                                         Example: 11:35 AM
'    
'    SortableDateTimePattern:          yyyy'-'MM'-'dd'T'HH':'mm':'ss
'                                         Example: 2012-05-28T11:35:00
'    
'    UniversalSortableDateTimePattern: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
'                                         Example: 2012-05-28 11:35:00Z
'    
'    YearMonthPattern:                 MMMM, yyyy
'                                         Example: May, 2012

For more information about this API, see Supplemental API remarks for DateTimeFormatInfo.

Constructors Properties AbbreviatedDayNames

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

AbbreviatedMonthGenitiveNames

Gets or sets a string array of abbreviated month names associated with the current DateTimeFormatInfo object.

AbbreviatedMonthNames

Gets or sets a one-dimensional string array that contains the culture-specific abbreviated names of the months.

AMDesignator

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

Calendar

Gets or sets the calendar to use for the current culture.

CalendarWeekRule

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

CurrentInfo

Gets a read-only DateTimeFormatInfo object that formats values based on the current culture.

DateSeparator

Gets or sets the string that separates the components of a date, that is, the year, month, and day.

DayNames

Gets or sets a one-dimensional string array that contains the culture-specific full names of the days of the week.

FirstDayOfWeek

Gets or sets the first day of the week.

FullDateTimePattern

Gets or sets the custom format string for a long date and long time value.

InvariantInfo

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

IsReadOnly

Gets a value indicating whether the DateTimeFormatInfo object is read-only.

LongDatePattern

Gets or sets the custom format string for a long date value.

LongTimePattern

Gets or sets the custom format string for a long time value.

MonthDayPattern

Gets or sets the custom format string for a month and day value.

MonthGenitiveNames

Gets or sets a string array of month names associated with the current DateTimeFormatInfo object.

MonthNames

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

NativeCalendarName

Gets the native name of the calendar associated with the current DateTimeFormatInfo object.

PMDesignator

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

RFC1123Pattern

Gets the custom format string for a time value that is based on the Internet Engineering Task Force (IETF) Request for Comments (RFC) 1123 specification.

ShortDatePattern

Gets or sets the custom format string for a short date value.

ShortestDayNames

Gets or sets a string array of the shortest unique abbreviated day names associated with the current DateTimeFormatInfo object.

ShortTimePattern

Gets or sets the custom format string for a short time value.

SortableDateTimePattern

Gets the custom format string for a sortable date and time value.

TimeSeparator

Gets or sets the string that separates the components of time, that is, the hour, minutes, and seconds.

UniversalSortableDateTimePattern

Gets the custom format string for a universal, sortable date and time string, as defined by ISO 8601.

YearMonthPattern

Gets or sets the custom format string for a year and month value.

Methods Explicit Interface Implementations See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4