Date date = new Date(0L);
Shouldn't it give me a zero date? Like 00/00/0000? Gives me Wed Dec 31 19:00:00 EST 1969
Per the javadocs, this constructor on Date
uses an offset from baseline time:
Allocates 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.
Presumably you are on EST, hence the result.
As an aside, I would not expect the result you noted to be produced by any conceivable Date
manipulation, since that's not even a valid date (month and day = 0).
From the Java API:
Date(long date): Allocates 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.
See: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html
The time is milliseconds since the epoch.
The epoch is 1/1/1970 GMT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With