asp.net.ph

DateTimeFormatInfo.GetAllDateTimePatterns Method ( )

System.Globalization Namespace   DateTimeFormatInfo Class


Returns all the standard patterns in which DateTime values can be formatted.

[ VB ]
Overloads Public Function GetAllDateTimePatterns ( ) As String ( ) 

[ C# ]
public string [ ] GetAllDateTimePatterns ( );

[ C++ ]
public: String* GetAllDateTimePatterns ( )  __gc [ ];

[ JScript ]
function GetAllDateTimePatterns ( ) : String [ ];

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.

<script language="C#" runat="server">
DateTime now;
string html;

public void Page_Load ( Object src, EventArgs e ) {
   // Create a new DateTimeFormatinfo instance.
   DateTimeFormatInfo myDtfi = new DateTimeFormatInfo ( );

   // Create a new DateTime object
   now = DateTime.Now;

   // Get and print all the patterns.
   String [ ] myPatterns = myDtfi.GetAllDateTimePatterns ( );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>All the patterns:</th></tr>";
   printValues ( myPatterns );

   // Get and print the patterns associated with some of the format characters.
   myPatterns = myDtfi.GetAllDateTimePatterns ( 'd' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'd' ) :</th></tr>";
   printValues ( myPatterns );

   myPatterns = myDtfi.GetAllDateTimePatterns ( 'D' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'D' ) :</th></tr>";
   printValues ( myPatterns );

   myPatterns = myDtfi.GetAllDateTimePatterns ( 'f' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'f' ) :</th></tr>";
   printValues ( myPatterns );

   myPatterns = myDtfi.GetAllDateTimePatterns ( 'F' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'F' ) :</th></tr>";
   printValues ( myPatterns );

   myPatterns = myDtfi.GetAllDateTimePatterns ( 'r' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'r' ) :</th></tr>";
   printValues ( myPatterns );

   myPatterns = myDtfi.GetAllDateTimePatterns ( 'R' );
   html += "<table align='center' class='data' width=80% cellspacing=1>";
   html += "<tr><th colspan=3>The patterns for DateTime.ToString ( 'R' ) :</th></tr>";
   printValues ( myPatterns );
}

void printValues ( String [ ] myArray ) {

   int i = 0;
   foreach ( String s in myArray ) {
      html += "<td>" + i++ + "</td>";
      html += "<td>" + s + "</td>";
      html += "<td>" + now.ToString ( s ) + "</td></tr>";
   }
   html += "</table><br>";
}
</script>
  C# VB

 Show me 

See Also

DateTimeFormatInfo Members   DateTimeFormatInfo.GetAllDateTimePatterns Overload List Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph