Export (0) Print
Expand All

DateTime Constructor (Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, DateTimeKind)

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

Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, second, millisecond, and Coordinated Universal Time (UTC) or local time for the specified calendar.

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

public DateTime (
	int year,
	int month,
	int day,
	int hour,
	int minute,
	int second,
	int millisecond,
	Calendar calendar,
	DateTimeKind kind
)
public DateTime (
	int year, 
	int month, 
	int day, 
	int hour, 
	int minute, 
	int second, 
	int millisecond, 
	Calendar calendar, 
	DateTimeKind kind
)
public function DateTime (
	year : int, 
	month : int, 
	day : int, 
	hour : int, 
	minute : int, 
	second : int, 
	millisecond : int, 
	calendar : Calendar, 
	kind : DateTimeKind
)

Parameters

year

The year (1 through the number of years in calendar).

month

The month (1 through the number of months in calendar).

day

The day (1 through the number of days in month).

hour

The hours (0 through 23).

minute

The minutes (0 through 59).

second

The seconds (0 through 59).

millisecond

The milliseconds (0 through 999).

calendar

The Calendar that applies to this DateTime.

kind

One of the DateTimeKind values that indicates whether year, month, day, hour, minute, second, and millisecond specify a local time, Coordinated Universal Time (UTC), or neither.

Exception typeCondition

ArgumentNullException

calendar is a null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

year is not in the range supported by calendar.

-or-

month is less than 1 or greater than the number of months in calendar.

-or-

day is less than 1 or greater than the number of days in month.

-or-

hour is less than 0 or greater than 23.

-or-

minute is less than 0 or greater than 59.

-or-

second is less than 0 or greater than 59.

-or-

millisecond is less than 0 or greater than 999.

ArgumentException

The specified time parameters evaluate to less than MinValue or more than MaxValue.

-or-

kind is not one of the DateTimeKind values.

The allowable values for year, month, and day parameters depend on the calendar parameter. An exception is thrown if the specified date and time cannot be expressed using calendar.

The System.Globalization namespace provides several calendars including GregorianCalendar and JulianCalendar.

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