jQuery in Action, 2nd edition*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Bartender

Joined: Oct 14, 2005
Posts: 18116
    
    8

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.
 
wood burning stoves
 
subject: currentTimeMillis() and Date.getTime()
 
Similar Threads
timezone issue
How to convert Data to Unix_Timestamp
Converting From String to java.sql.Date
Parsing time string
preparedStatement.setDate and java.util.Date