Represents an instant in time, typically expressed as a date and time of day.
Constructor Summary
DateTime(int year, int month, int day)
Initializes a new instance of the DateTime object to the specified year, month, and day.
DateTime(int year, int month, int day, int hour, int minute, int second)
Initializes a new instance of the DateTime object to the specified year, month, day, hour, minute, and second.
DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
Initializes a new instance of the DateTime object to the specified year, month, day, hour, minute, second, and millisecond.
DateTime(java.util.Date date)
Initializes a new instance of the DateTime object to the specified Date object
DateTime(java.util.Calendar cld)
Initializes a new instance of the DateTime object to the specified Calendar object
Compares the value of this instance to a specified DateTime value
and returns an integer that indicates whether this instance is earlier than,
the same as, or later than the specified DateTime value.
Compares the value of this instance to a specified object that contains a
specified DateTime value, and returns an integer that indicates whether
this instance is earlier than, the same as, or later than the specified DateTime value.
Adds the specified number of milliseconds to the value of this instance.
Parameters:
value - A number of whole and fractional milliseconds. The value parameter can be negative or positive. Note that this value is rounded to the nearest integer.
Returns:
A DateTime object whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by value.
Adds the specified number of years to the value of this instance.
Parameters:
value - A number of years. The value parameter can be negative or positive.
Returns:
A DateTime object whose value is the sum of the date and time represented by this instance and the number of years represented by value.
compareTo
public int compareTo(java.lang.Object value)
Compares the value of this instance to a specified object that contains a
specified DateTime value, and returns an integer that indicates whether
this instance is earlier than, the same as, or later than the specified DateTime value.
Parameters:
value - A boxed DateTime object to compare, or null.
Returns:
A signed number indicating the relative values of this instance and value.
Value Description Less than zero This instance is earlier than value. Zero
This instance is the same as value. Greater than zero This instance is later
than value, or value is null.
Compares the value of this instance to a specified DateTime value
and returns an integer that indicates whether this instance is earlier than,
the same as, or later than the specified DateTime value.
Parameters:
value - A DateTime object to compare.
Returns:
A signed number indicating the relative values of this instance and the value
parameter. Value Description Less than zero This instance is earlier than
value. Zero This instance is the same as value. Greater than zero This instance
is later than value.
hashCode
public int hashCode()
Returns the hash code for this instance.
Returns:
A 32-bit signed integer hash code.
equals
public boolean equals(java.lang.Object value)
Returns a value indicating whether this instance is equal to a specified object.
Parameters:
value - An object to compare to this instance.
Returns:
true if value is an instance of DateTime and equals the value of this instance; otherwise, false.
getDay
public int getDay()
Gets the day of the month represented by this instance.
Returns:
The day component, expressed as a value between 1 and 31.
getDayOfWeek
public int getDayOfWeek()
Gets the day of the week represented by this instance.
Returns:
the day of the week of this DateTime value.
getDayOfYear
public int getDayOfYear()
Gets the day of the year represented by this instance.
Returns:
The day of the year, expressed as a value between 1 and 366.
getHour
public int getHour()
Gets the hour component of the date represented by this instance.
Returns:
The hour component, expressed as a value between 0 and 23.
getMillisecond
public int getMillisecond()
Gets the milliseconds component of the date represented by this instance.
Returns:
The milliseconds component, expressed as a value between 0 and 999.
getMinute
public int getMinute()
Gets the minute component of the date represented by this instance.
Returns:
The minute component, expressed as a value between 0 and 59.
getMonth
public int getMonth()
Gets the month component of the date represented by this instance.
Returns:
The month component, expressed as a value between 1 and 12.