System.Globalization.DateTimeStyles Enumeration

Assembly: Mscorlib.dll
Namespace: System.Globalization
Summary
Defines the formatting options that customize how the DateTime.Parse and DateTime.ParseExact methods parse a string.
C# Syntax:
[Flags]
[Serializable]
public enum DateTimeStyles
Remarks
The DateTimeStyles.NoCurrentDateDefault value is the only value that is useful with the DateTime.Parse method, because DateTime.Parse always ignores leading, trailing, and inner white-space characters.

The DateTime.ParseExact can use any of DateTimeStyles values. If none of the Allow* values are selected, the input string must have exactly the same white-space characters as in the format string.

If the string does not contain any indication of the time zone, DateTime.Parse and DateTime.ParseExact read the date and time based on the system's time zone setting. To convert the date and time to the Universal Time or Greenwich mean time (GMT), use the DateTimeStyles.AdjustToUniversal value. The same effect can be achieved using DateTime.ToUniversalTime; however, using the DateTimeStyles.AdjustToUniversal value with DateTime.Parse or DateTime.ParseExact is more efficient.

See also:
System.Globalization Namespace | DateTime.Parse | DateTime.ParseExact

System.Globalization.DateTimeStyles Member List:

Public Fields
AdjustToUniversal Indicates that the date and time must be converted to Universal Time or Greenwich mean time (GMT).
AllowInnerWhite Indicates that extra white space characters in the middle of the string must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns.
AllowLeadingWhite Indicates that leading white space characters must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns.
AllowTrailingWhite Indicates that trailing white space characters must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns.
AllowWhiteSpaces Indicates that extra white space characters anywhere in the string must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns. This value is a combination of the DateTimeStyles.AllowLeadingWhite, DateTimeStyles.AllowTrailingWhite, and DateTimeStyles.AllowInnerWhite values.
NoCurrentDateDefault Indicates that, if the parsed string contains only the time and not the date, the DateTime.Parse and DateTime.ParseExact methods assume the Gregorian date with year = 1, month = 1, and day = 1. If this value is not used, the current date is assumed.
None Indicates that the default formatting options must be used. This is the default style for DateTime.Parse and DateTime.ParseExact.

Hierarchy:


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.