The class Date represents a specific instant in time, with millisecond precision.
The following representations are used when accepting or returning year, month, date, hours, minutes, and seconds values.
A date may be specified as January 32 and is interpreted as meaning February 1.
| Constructor | Summary |
|---|---|
| Date() | Creates a Date object and initializes it with the time at which it was allocated. |
| Date(long date) | Creates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. |
Compare two Date value
| Return | Method | Summary |
|---|---|---|
| boolean | after(Date when) | Tests if this date is after the specified date. |
| boolean | before(Date when) | Tests if this date is before the specified date. |
| int | compareTo(Date anotherDate) | Compares two Dates for ordering. |
| boolean | equals(Object obj) | Compares two dates for equality. |
Convert date value to long value in milliseconds
| Return | Method | Summary |
|---|---|---|
| long | getTime() | Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. |
| void | setTime(long time) | Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT. |
Convert Date value to String
| Return | Method | Summary |
|---|---|---|
| String | toString() | Converts this Date object to a String of the form: |
java2s.com | | Contact Us | Privacy Policy |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |