File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes currentTimeMillis() and Date.getTime() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "currentTimeMillis() and Date.getTime()" Watch "currentTimeMillis() and Date.getTime()" New topic
Author

currentTimeMillis() and Date.getTime()

Shrihan De Mel
Greenhorn

Joined: Jan 15, 2007
Posts: 3
hi

is there a difference between the format returned by System.currentTimeMillis() and Date.getTime()

to further clarify, can we directly compare two variables that possess values from each one of the above methods, as if both of them are assigned from one of the above ways

your help if much appreciated

Shrihan
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10

They both return long values, so there is no difference in the format. You can directly compare two long values, yes.

You may have meant to ask if you should expect those two long values to be the same, although you really only asked about the format and not about the content. Both contain a number of milliseconds since a certain point of time, so if you evaluate the two expressions at the same instant, you should expect to get the same value in both cases.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: currentTimeMillis() and Date.getTime()
 
It's not a secret anymore!