Thursday 5 April 2012

Class - Date


Date

The date class encapsulates the current date and time.
constructors:

Date( )
Date(long millisec)
In the first constructor initialize the object with the current date & time.

In the second constructor accepts one argument that equals the number of milliseconds that have elapsed since midnight january 1,1970.

Method:

boolean after(Date date)
  Returns true if the invoking Date object contains a date that is later than The one specified by date. Otherwise it returns false.

boolean before(Date date)
  Returns true if the invoking Date object contains a date that is earlier than The one specified by date. Otherwise it returns false.

object clone()
  Duplicates the invoking date object.

int compareto(Date date)
  Compares the value of the invoking object with that of date. Returns 0 if the values are equal. Returns a negative value if the invoking object is earlier than date. Returns a positive value if the invoking object is later than date.

 long getTime()
  returns the member of milliseconds that have elapsed since january 1,1970.

int hasecode()
  returns a hasecode for the invoking object

void setTime(long time)
  sets the time and date as specified by time,which represent an elapsed time in
 milliseconds from midnight 1,january 1970.

String toString( )
Converts the invoking Date object into a string and returns the result.

Posted By : Ruchita Pandya

No comments:

Post a Comment