Export (0) Print
Expand All

DateTimeStyles Enumeration

Defines the formatting options that customize how the DateTime.Parse and DateTime.ParseExact methods parse a string.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

[Visual Basic]
<Flags>
<Serializable>
Public Enum DateTimeStyles
[C#]
[Flags]
[Serializable]
public enum DateTimeStyles
[C++]
[Flags]
[Serializable]
__value public enum DateTimeStyles
[JScript]
public
   Flags
 Serializable
enum DateTimeStyles

Remarks

The 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 AdjustToUniversal value. The same effect can be achieved using DateTime.ToUniversalTime; however, using the AdjustToUniversal value with DateTime.Parse or DateTime.ParseExact is more efficient.

Members

Member name Description Value
AdjustToUniversal

Supported by the .NET Compact Framework.

Indicates that the date and time must be converted to Universal Time or Greenwich mean time (GMT). 16
AllowInnerWhite

Supported by the .NET Compact Framework.

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. 4
AllowLeadingWhite

Supported by the .NET Compact Framework.

Indicates that leading white space characters must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns. 1
AllowTrailingWhite

Supported by the .NET Compact Framework.

Indicates that trailing white space characters must be ignored during parsing, except if those white space characters occur in the DateTimeFormatInfo format patterns. 2
AllowWhiteSpaces

Supported by the .NET Compact Framework.

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 AllowLeadingWhite, AllowTrailingWhite, and AllowInnerWhite values. 7
NoCurrentDateDefault

Supported by the .NET Compact Framework.

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. 8
None

Supported by the .NET Compact Framework.

Indicates that the default formatting options must be used. This is the default style for DateTime.Parse and DateTime.ParseExact. 0

Requirements

Namespace: System.Globalization

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

System.Globalization Namespace | DateTime.Parse | DateTime.ParseExact

Show:
© 2015 Microsoft