0

Possible Duplicate:
System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

So far I've seen two ways of getting time in Java:

Calendar.getInstance().getTimeInMillis();

and

System.currentTimeMillis();

I know that the latter is UNIX time, i.e. time passed from 1970... But, when to use first and when to use second time? Thanks.

Community
  • 1
  • 1
  • In short - it is the same. Use System.currentTimeMillis(), it is always in UTC (w/o zone offset and dst). – d1e Jul 02 '12 at 08:06

1 Answers1

0

If you need the semantics of the second one (get the current time), then don't use the first one. The first one is only needed when you want to convert a specific moment of your choosing to the epoch number. Keep in mind that currentTimeMillis gives epoch*1000 time.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436