DateTime defines constructors that accept integers for the year, month, day, hour, minute, second, and millisecond:
public DateTime (int year, int month, int day); public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond);
If you specify only a date, the time is implicitly set to midnight (0:00).
DateTime constructors accepts a DateTimeKind-an enum with the following values:
Value | Meaning |
---|---|
Unspecified | Unspecified is the default and it means that the DateTime is time-zone-agnostic. |
Local | Local means relative to the local time zone on the current computer. |
Utc | GMT time zone |
A DateTime's Kind property returns its DateTimeKind.
DateTime's constructors can also accept a Calendar object as well.
You can specify a date using any of the Calendar subclasses defined in System.Globalization. For example:
using System; class MainClass/*from w ww .j ava2 s .c o m*/ { public static void Main(string[] args) { DateTime d = new DateTime (5765, 1, 1, new System.Globalization.HebrewCalendar()); Console.WriteLine (d); } }