This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "currentTimeMillis() and Date.getTime()" Watch "currentTimeMillis() and Date.getTime()" New topic

currentTimeMillis() and Date.getTime()

Shrihan De Mel

Joined: Jan 15, 2007
Posts: 3

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

Paul Clapham

Joined: Oct 14, 2005
Posts: 19351

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.
rocket mass heater kickstarter
subject: currentTimeMillis() and Date.getTime()