my dog learned polymorphism
The moose likes Beginning Java and the fly likes new Date and currentTimeMillis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "new Date and currentTimeMillis" Watch "new Date and currentTimeMillis" New topic

new Date and currentTimeMillis

D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Do new Date() and new Date(System..currentTimeMillis()) suppose to be equal?
In Linux RH, JDK 1.6 result has time difference about 95 days. The system stays on for more than one year.

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
marc weber

Joined: Aug 31, 2004
Posts: 11343

Originally posted by D Rog:
Do new Date() and new Date(System..currentTimeMillis()) suppose to be equal? ...

Yes. I'm using Java 5 on a Mac, but in the source code for java.util.Date, the no-args constructor is simply...

I tested this with...

[ February 25, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Tried the same on a Windows Machine, jdk1.6 :

Mon Feb 26 11:18:29 JST 2007
Mon Feb 26 11:18:29 JST 2007

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: new Date and currentTimeMillis
It's not a secret anymore!