Date class Methods in Java

java.util.Date

The class Date represents a specific instant in time, with millisecond precision.

Some methods of Date class.


after(Date)This method tests if this date is after the specified date.


before(Date)This method tests if this date is before the specified date.


clone()This method returns a copy of this object.


compareTo(Date)This method compares two Dates for ordering.


equals(Object)This method compares two dates for equality.


Date.from(Instant)This method obtains an instance of Date from an Instant object.


getTime()This method returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.


hashCode()This method returns a hash code value for this object.


setTime(long)This method sets this Date object to represent a point in time that is time milliseconds after January 1, 1970, 00:00:00 GMT.


toInstant()This method converts this Date object to an Instant.


 toString()This method converts this Date object to a string of the form: dow mon dd hh:mm: ss zzz yyyy



No comments:

Post a Comment