C# DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)
Description
DateTime DateTime(Int32, Int32, Int32, Int32, Int32, Int32,
Int32, DateTimeKind)
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.
Syntax
DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)
has the following syntax.
public DateTime(/*w w w .ja v a2 s. com*/
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
DateTimeKind kind
)
Parameters
DateTime.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)
has the following parameters.
year
- The year (1 through 9999).month
- The month (1 through 12).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).kind
- One of the enumeration values that indicates whether year, month, day, hour, minute, second, and millisecond specify a local time, Coordinated Universal Time (UTC), or neither.
Example
The following example uses the DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind) constructor to instantiate a DateTime value.
using System;//w w w .ja v a 2s.co m
public class MainClass{
public static void Main(String[] argv){
DateTime date1 = new DateTime(2010, 8, 18, 16, 32, 18, 500,
DateTimeKind.Local);
System.Console.WriteLine("{0:M/dd/yyyy h:mm:ss.fff tt} {1}", date1, date1.Kind);
}
}
The code above generates the following result.