System Namespace DateTime Structure
Converts the value of this instance to its equivalent string representation using the specified format and culture-specific format information.
[ VB ]
<Serializable>
NotOverridable Overloads Public Function ToString ( _
ByVal format As String, _
ByVal provider As IFormatProvider _
) As String
[ C# ]
[ Serializable ]
public string ToString (
string format,
IFormatProvider provider
);
[ C++ ]
[ Serializable ]
public: __sealed String* ToString (
String* format,
IFormatProvider* provider
);
[ JScript ]
public Serializable
function ToString (
format : String,
provider : IFormatProvider
) : String;
- format
- A format string.
- provider
- An IFormatProvider that supplies culture-specific formatting information.
A string representation of value of this instance as specified by format and provider.
Exception Type |
Condition |
FormatException |
The length of format is 1, and it is not one of the format specifier characters defined for DateTimeFormatInfo.
-or-
format does not contain a valid custom format pattern.
|
The format parameter can contain either a format specifier character or a custom format pattern. For more information, see the summary page for System.Globalization.DateTimeFormatInfo.
If format is a null reference ( Nothing in Visual Basic ) or an empty string ( "" ), the standard format specifier, 'G', is used.
The provider parameter is typically an instance of DateTimeFormatInfo. If provider is a null reference ( Nothing ), the DateTimeFormatInfo associated with the current culture is used. For more information, see CultureInfo.CurrentCulture.
The below shows the output of using this overload of ToString for each of the available cultures.
Show me
DateTime Members DateTime.ToString Overload List DateTimeFormatInfo CultureInfo