Export (0) Print
Expand All
Expand Minimize

DateTime.SpecifyKind Method

Note: This method is new in the .NET Framework version 2.0.

Creates a new DateTime object that represents the same time as the specified DateTime, but is designated in either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value.

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

public:
static DateTime SpecifyKind (
	DateTime value, 
	DateTimeKind kind
)
public static DateTime SpecifyKind (
	DateTime value, 
	DateTimeKind kind
)
public static function SpecifyKind (
	value : DateTime, 
	kind : DateTimeKind
) : DateTime

Parameters

value

A DateTime object.

kind

One of the DateTimeKind values.

Return Value

A new DateTime object consisting of the same time represented by the value parameter and the DateTimeKind value specified by the kind parameter.

A DateTime object consists of a Kind field that indicates whether the time value is based on local time, Coordinated Universal Time (UTC), or neither, and a Ticks field that contains a time value measured in 100-nanosecond ticks. The SpecifyKind method creates a new DateTime object using the specified kind parameter and the original time value.

The SpecifyKind method is useful in interoperability scenarios where you receive a DateTime object with an unspecified Kind field, but you can determine by independent means that the Ticks field represents local time or UTC.

The following code example uses the SpecifyKind method to demonstrate how the Kind property influences the ToLocalTime and ToUniversalTime conversion methods.

No code example is currently available or this language may not be supported.

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

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft