Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DateTimeStyles Enumeration

Defines the formatting options that customize string parsing for the Parse and ParseExact methods.

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

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

[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum DateTimeStyles
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum DateTimeStyles
SerializableAttribute 
FlagsAttribute 
ComVisibleAttribute(true) 
public enum DateTimeStyles
 Member nameDescription
Supported by the .NET Compact FrameworkAdjustToUniversalDate and time are returned as a Coordinated Universal Time (UTC). If the input string denotes a local time, through a time zone specifier or AssumeLocal, the date and time are converted from the local time to UTC. If the input string denotes a UTC time, through a time zone specifier or AssumeUniversal, no conversion occurs. If the input string does not denote a local or UTC time, no conversion occurs and the resulting Kind property is Unspecified.  

Cannot be used with RoundTripKind.

Supported by the .NET Compact FrameworkAllowInnerWhiteExtra white-space characters in the middle of the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. 
Supported by the .NET Compact FrameworkAllowLeadingWhiteLeading white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. 
Supported by the .NET Compact FrameworkAllowTrailingWhiteTrailing white-space characters must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. 
Supported by the .NET Compact FrameworkAllowWhiteSpacesExtra white-space characters anywhere in the string must be ignored during parsing, except if they occur in the DateTimeFormatInfo format patterns. This value is a combination of the AllowLeadingWhite, AllowTrailingWhite, and AllowInnerWhite values. 
Supported by the .NET Compact FrameworkAssumeLocalIf 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 FrameworkAssumeUniversalIf no time zone is specified in the parsed string, the string is assumed to denote a UTC.  

Cannot be used with AssumeLocal or RoundtripKind.

Supported by the .NET Compact FrameworkNoCurrentDateDefaultIf the parsed string contains only the time and not the date, the parsing 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 FrameworkNoneDefault formatting options must be used. This value represents the default style for DateTime.Parse, DateTime.ParseExact, and DateTime.TryParse
Supported by the .NET Compact FrameworkRoundtripKindThe DateTimeKind field of a date is preserved 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 is selected, the input string must have exactly the same white-space characters as the format string.

If the input string does not contain any indication of the time zone, Parse and ParseExact read the date and time based on the time zone setting for the operating system. To convert the date and time to the Universal Time or Greenwich Mean Time (GMT), the application should use the AdjustToUniversal value. The same effect can be achieved using ToUniversalTime. However, using the AdjustToUniversal value with Parse or ParseExact is more efficient.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.