DateTime

DateTime class

Represents an instant in time, typically expressed as a date and time of day.

DateTime(year, month, day)

Initializes a new instance of the DateTime object to the specified year, month, and day.

Methods

NameDescription
toDateConverts the value of the current DateTime object to Date object.
toCalendarConverts the value of the current DateTime object to Calendar object.
addDaysAdds the specified number of days to the value of this instance.
addHoursAdds the specified number of hours to the value of this instance.
addMillisecondsAdds the specified number of milliseconds to the value of this instance.
addMinutesAdds the specified number of minutes to the value of this instance.
addMonthsAdds the specified number of months to the value of this instance.
addSecondsAdds the specified number of seconds to the value of this instance.
addYearsAdds the specified number of years to the value of this instance.
compareToCompares the value of this instance to a specified object that contains a specified DateTime value, and returns an integ
hashCodeReturns the hash code for this instance.
equalsReturns a value indicating whether this instance is equal to a specified object.
getDayGets the day of the month represented by this instance.
getDayOfWeekGets the day of the week represented by this instance.
getDayOfYearGets the day of the year represented by this instance.
getHourGets the hour component of the date represented by this instance.
getMillisecondGets the milliseconds component of the date represented by this instance.
getMinuteGets the minute component of the date represented by this instance.
getMonthGets the month component of the date represented by this instance.
getNowGets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
getSecondGets the seconds component of the date represented by this instance.
getYearGets the year component of the date represented by this instance.
toStringConverts the value of the current DateTime object to its equivalent string representation.