Initializes a new instance of the DateTime class from the specified year, month, and day in the specified Calendar.
[Visual Basic] Overloads Public Sub New( _ ByVal year As Integer, _ ByVal month As Integer, _ ByVal day As Integer, _ ByVal calendar As Calendar _ ) [C#] public DateTime( int year, int month, int day, Calendar calendar ); [C++] public: DateTime( int year, int month, int day, Calendar* calendar ); [JScript] public function DateTime( year : int, month : int, day : int, calendar : Calendar );
Exception Type | Condition |
---|---|
ArgumentException | If the calendar is a null reference (in Visual Basic Nothing) . |
ArgumentException | If the year is less than 1 or greater than 9999. |
ArgumentException | If the month specifies a value outside the range of the specified calendar. |
ArgumentException | If the day is less than 1 or greater than the number of days in the specified month. |
This DateTime class initializes a new instance of the DateTime from the given year, month, and day in the specified calendar. The time of day of the resulting DateTime is always midnight.
The allowable parameter values for year, month, and day depend upon the specified calendar that is used. The Globalization Namespace package provides implementation of the GregorianCalendar, JulianCalendar, and other calendars.
An argument is out of range for the specified calendar, if it is not possible to represent the specified arguments as a DateTime value. This is dependent upon the specified calendar. For example, if the Gregorian calendar is used, the value of day cannot be 8.
DateTime Structure | DateTime Members | System Namespace | DateTime Constructor Overload List | Int32 | Calendar