System.Globalization Namespace CultureInfo Class
Sets or retrieves a DateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.
[ VB ]
Overridable Public Property DateTimeFormat As DateTimeFormatInfo
[ C# ]
public virtual DateTimeFormatInfo DateTimeFormat {get; set;}
[ C++ ]
public: __property virtual DateTimeFormatInfo* get_DateTimeFormat ( );
public: __property virtual void set_DateTimeFormat ( DateTimeFormatInfo* );
[ JScript ]
function get DateTimeFormat ( ) : DateTimeFormatInfo;
public function set DateTimeFormat ( DateTimeFormatInfo );
A DateTimeFormatInfo that defines the culturally appropriate format of displaying dates and times.
Exception Type |
Condition |
ArgumentNullException |
The property is set to a null reference ( Nothing in Visual Basic ). |
A DateTimeFormatInfo can be created only for the invariant culture or for specific cultures, not for neutral cultures.
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 UseUserOverride property is set to true, the properties of the DateTimeFormat instance, the NumberFormat instance, and the 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 OptionalCalendars ), the results of the methods and the values of the properties are undefined.
The cultures are generally grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures.
The invariant culture is culture-insensitive. You can specify the invariant culture by name using an empty string ( "" ). InvariantCulture retrieves an instance of the invariant culture. It is associated with the English language but not with any country/region. It can be used in almost any method in the Globalization namespace that requires a culture. The invariant culture must be used only by processes that require culture-independent results, such as system services; otherwise, it produces results that might be linguistically incorrect or culturally inappropriate.
A neutral culture is a culture that is associated with a language but not with a country/region. A specific culture is a culture that is associated with a language and a country/region. For example, "fr" is a neutral culture and "fr-FR" is a specific culture. Note that "zh-CHS" ( Simplified Chinese ) and "zh-CHT" ( Traditional Chinese ) are neutral cultures.
CultureInfo Members DateTimeFormatInfo GetFormat NumberFormat