• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

currentTimeMillis() and Date.getTime()

 
Shrihan De Mel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20719
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic