Rajat Gupta
Rajat Gupta

Reputation: 26587

Does System.currentTimeMillis represent UTC time?

Does System.currentTimeMillis() represent UTC time or local system time?

Upvotes: 18

Views: 10965

Answers (2)

Greyer Sting
Greyer Sting

Reputation: 85

UTC according to oracle.com. http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#currentTimeMillis

"currentTimeMillis

Returns:

the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC."

Upvotes: 3

Jon Skeet
Jon Skeet

Reputation: 1499770

UTC - it's the number of milliseconds since midnight on January 1st 1970 UTC (modulo leap seconds, potentially).

Obviously it's reliant on the local system clock, but it doesn't depend on the local system time zone.

(It's a shame that the Javadoc isn't clearer on this, admittedly.)

Upvotes: 28

Related Questions