DateTime

Inheritance: java.lang.Object

public class DateTime

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

Constructors

ConstructorDescription
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(Date date)Initializes a new instance of the DateTime object to the specified Date object
DateTime(Calendar cld)Initializes a new instance of the DateTime object to the specified Calendar object

Methods

MethodDescription
addDays(double value)Adds the specified number of days to the value of this instance.
addHours(double value)Adds the specified number of hours to the value of this instance.
addMilliseconds(double value)Adds the specified number of milliseconds to the value of this instance.
addMinutes(double value)Adds the specified number of minutes to the value of this instance.
addMonths(int months)Adds the specified number of months to the value of this instance.
addSeconds(double value)Adds the specified number of seconds to the value of this instance.
addYears(int value)Adds the specified number of years to the value of this instance.
compareTo(DateTime value)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.
compareTo(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.
equals(Object value)Returns a value indicating whether this instance is equal to a specified object.
getClass()
getDay()Gets the day of the month represented by this instance.
getDayOfWeek()Gets the day of the week represented by this instance.
getDayOfYear()Gets the day of the year represented by this instance.
getHour()Gets the hour component of the date represented by this instance.
getMillisecond()Gets the milliseconds component of the date represented by this instance.
getMinute()Gets the minute component of the date represented by this instance.
getMonth()Gets the month component of the date represented by this instance.
getNow()Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
getSecond()Gets the seconds component of the date represented by this instance.
getYear()Gets the year component of the date represented by this instance.
hashCode()Returns the hash code for this instance.
notify()
notifyAll()
toCalendar()Converts the value of the current DateTime object to Calendar object.
toDate()Converts the value of the current DateTime object to Date object.
toLocalTime()Converts the value of the current DateTime object to local time.
toString()Converts the value of the current DateTime object to its equivalent string representation.
toUniversalTime()Converts the value of the current DateTime object to Coordinated Universal Time(UTC).
wait()
wait(long arg0)
wait(long arg0, int arg1)

DateTime(int year, int month, int day)

public DateTime(int year, int month, int day)

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

Parameters:

ParameterTypeDescription
yearintThe year (1 through 9999).
monthintThe month (1 through 12).
dayintThe day (1 through the number of days in month).

DateTime(int year, int month, int day, int hour, int minute, int second)

public 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.

Parameters:

ParameterTypeDescription
yearintThe year (1 through 9999).
monthintThe month (1 through 12).
dayintThe day (1 through the number of days in month).
hourintThe hours (0 through 23).
minuteintThe minutes (0 through 59).
secondintThe seconds (0 through 59).

DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)

public 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.

Parameters:

ParameterTypeDescription
yearintThe year (1 through 9999).
monthintThe month (1 through 12).
dayintThe day (1 through the number of days in month).
hourintThe hours (0 through 23).
minuteintThe minutes (0 through 59).
secondintThe seconds (0 through 59).
millisecondintThe milliseconds (0 through 999).

DateTime(Date date)

public DateTime(Date date)

Initializes a new instance of the DateTime object to the specified Date object

Parameters:

ParameterTypeDescription
datejava.util.DateThe Date object

DateTime(Calendar cld)

public DateTime(Calendar cld)

Initializes a new instance of the DateTime object to the specified Calendar object

Parameters:

ParameterTypeDescription
cldjava.util.CalendarThe Calendar object

addDays(double value)

public DateTime addDays(double value)

Adds the specified number of days to the value of this instance.

Parameters:

ParameterTypeDescription
valuedoubleA number of whole and fractional days. The value parameter can be negative or positive.

Returns: DateTime - A DateTime object whose value is the sum of the date and time represented by this instance and the number of days represented by value.

addHours(double value)

public DateTime addHours(double value)

Adds the specified number of hours to the value of this instance.

Parameters:

ParameterTypeDescription
valuedoubleA number of whole and fractional hours. The value parameter can be negative or positive.

Returns: DateTime - A DateTime object whose value is the sum of the date and time represented by this instance and the number of hours represented by value.

addMilliseconds(double value)

public DateTime addMilliseconds(double value)

Adds the specified number of milliseconds to the value of this instance.

Parameters:

ParameterTypeDescription
valuedoubleA 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: DateTime - 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.

addMinutes(double value)

public DateTime addMinutes(double value)

Adds the specified number of minutes to the value of this instance.

Parameters:

ParameterTypeDescription
valuedoubleA number of whole and fractional minutes. The value parameter can be negative or positive.

Returns: DateTime - A DateTime object whose value is the sum of the date and time represented by this instance and the number of minutes represented by value.

addMonths(int months)

public DateTime addMonths(int months)

Adds the specified number of months to the value of this instance.

Parameters:

ParameterTypeDescription
monthsintA number of months. The months parameter can be negative or positive.

Returns: DateTime - A DateTime object whose value is the sum of the date and time represented by this instance and months.

addSeconds(double value)

public DateTime addSeconds(double value)

Adds the specified number of seconds to the value of this instance.

Parameters:

ParameterTypeDescription
valuedoubleA number of whole and fractional seconds. The value parameter can be negative or positive.

Returns: DateTime - A DateTime object whose value is the sum of the date and time represented by this instance and the number of seconds represented by value.

addYears(int value)

public DateTime addYears(int value)

Adds the specified number of years to the value of this instance.

Parameters:

ParameterTypeDescription
valueintA number of years. The value parameter can be negative or positive.

Returns: DateTime - 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(DateTime value)

public int compareTo(DateTime value)

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:

ParameterTypeDescription
valueDateTimeA DateTime object to compare.

Returns: int - 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.

compareTo(Object value)

public int compareTo(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:

ParameterTypeDescription
valuejava.lang.ObjectA boxed DateTime object to compare, or null.

Returns: int - 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.

equals(Object value)

public boolean equals(Object value)

Returns a value indicating whether this instance is equal to a specified object.

Parameters:

ParameterTypeDescription
valuejava.lang.ObjectAn object to compare to this instance.

Returns: boolean - true if value is an instance of DateTime and equals the value of this instance; otherwise, false.

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getDay()

public int getDay()

Gets the day of the month represented by this instance.

Returns: int - 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: int - the day of the week of this DateTime value.

getDayOfYear()

public int getDayOfYear()

Gets the day of the year represented by this instance.

Returns: int - 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: int - 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: int - 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: int - 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: int - The month component, expressed as a value between 1 and 12.

getNow()

public static DateTime getNow()

Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.

Returns: DateTime - A DateTime object whose value is the current local date and time.

getSecond()

public int getSecond()

Gets the seconds component of the date represented by this instance.

Returns: int - The seconds, between 0 and 59.

getYear()

public int getYear()

Gets the year component of the date represented by this instance.

Returns: int - The year, between 1 and 9999.

hashCode()

public int hashCode()

Returns the hash code for this instance.

Returns: int - A 32-bit signed integer hash code.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

toCalendar()

public Calendar toCalendar()

Converts the value of the current DateTime object to Calendar object.

Returns: java.util.Calendar - Calendar object

toDate()

public Date toDate()

Converts the value of the current DateTime object to Date object.

Returns: java.util.Date - Date object

toLocalTime()

public DateTime toLocalTime()

Converts the value of the current DateTime object to local time.

Returns: DateTime - A DateTime object of local

toString()

public String toString()

Converts the value of the current DateTime object to its equivalent string representation.

Returns: java.lang.String - A string representation of the value of the current DateTime object.

toUniversalTime()

public DateTime toUniversalTime()

Converts the value of the current DateTime object to Coordinated Universal Time(UTC).

Returns: DateTime - A DateTime object of UTC

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int