Export (0) Print
Expand All
0 out of 4 rated this helpful - Rate this topic

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.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[FlagsAttribute] 
public enum DateTimeStyles
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute FlagsAttribute() */ 
public enum DateTimeStyles
SerializableAttribute 
ComVisibleAttribute(true) 
FlagsAttribute 
public enum DateTimeStyles
 Member nameDescription
Supported by the .NET Compact FrameworkAdjustToUniversalIndicates that the date and time will be returned as a Coordinated Universal Time (UTC). If the input string denoted a Local time (through a time zone specifier or AssumeLocal) then the date and time is converted from the local time zone to UTC. If the input string denoted a UTC time (through a time zone specifier or AssumeUniversal) then no conversion occurs. If the input string did not denote a Local or UTC time (no time zone specifier, and neither AssumeLocal nor AssumeUniversal was included), then no conversion occurs and the Kind of the resulting DateTime is Unspecified. Cannot be used with RoundTripKind
Supported by the .NET Compact FrameworkAllowInnerWhiteIndicates 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. 
Supported by the .NET Compact FrameworkAllowLeadingWhiteIndicates that leading white-space characters must be ignored during parsing, except if those white-space characters occur in the DateTimeFormatInfo format patterns. 
Supported by the .NET Compact FrameworkAllowTrailingWhiteIndicates that trailing white-space characters must be ignored during parsing, except if those white-space characters occur in the DateTimeFormatInfo format patterns. 
Supported by the .NET Compact FrameworkAllowWhiteSpacesIndicates 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. 
Supported by the .NET Compact FrameworkAssumeLocalIndicates that if no time zone is specified in the parsed string, the string is assumed to denote a local time. Cannot be used with AssumeUniversal or RoundtripKind
Supported by the .NET Compact FrameworkAssumeUniversalIndicates that if no time zone is specified in the parsed string, the string is assumed to denote a Coordinated Universal Time (UTC). Cannot be used with AssumeLocal or RoundtripKind
Supported by the .NET Compact FrameworkNoCurrentDateDefaultIndicates 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. 
Supported by the .NET Compact FrameworkNoneIndicates that the default formatting options must be used. This is the default style for DateTime.Parse, DateTime.ParseExact, and DateTime.TryParse
Supported by the .NET Compact FrameworkRoundtripKindPreserves the DateTimeKind field of a date when a DateTime object is converted to a string and the string is then converted back to a DateTime object. 

The ParseExact method can use any of DateTimeStyles values. However, 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 input 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.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.