System.ComponentModel.DateTimeConverter Class

Provides a type converter to convert DateTime objects to and from various other representations.

See Also: DateTimeConverter Members


public class DateTimeConverter : TypeConverter


This converter can only convert a DateTime object to and from a string.

The erload:System.ComponentModel.TypeConverter.ConvertFrom method uses the DateTime.Parse(string) method of the DateTime class to convert from a string.

The erload:System.ComponentModel.TypeConverter.ConvertTo method uses the current culture, if a System.Globalization.CultureInfo is not supplied. Generally, erload:System.ComponentModel.TypeConverter.ConvertTo uses the System.Globalization.DateTimeFormatInfo.ShortDatePattern property to format a date and System.Globalization.DateTimeFormatInfo.ShortDatePattern with the System.Globalization.DateTimeFormatInfo.ShortTimePattern property to format a date and time. If the System.Globalization.CultureInfo.InvariantCulture property is passed, erload:System.ComponentModel.TypeConverter.ConvertTo uses yyyy-mm-dd to format a date and object.ToString to format a date and time.

For more information about type converters, see the System.ComponentModel.TypeConverter base class and How to: Implement a Type Converter.


You should never create an instance of System.ComponentModel.DateTimeConverter. Instead, call the TypeDescriptor.GetConverter(object) method of the System.ComponentModel.TypeDescriptor class. For more information, see the examples in the System.ComponentModel.TypeConverter base class.


Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,,