Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get GMT Time in Milliseconds using JAVA [duplicate]

Tags:

java

uti

Possible Duplicate:
Get GMT Time in Java

I have taken the reference of the below 2 link :

link1 link2

But I want the GMT date in milliseconds.

Thanks In Advance.

like image 734
mayur rahatekar Avatar asked Oct 23 '12 09:10

mayur rahatekar


2 Answers

You can use System.currentTimeMillis() it returns "the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC."

long time = System.currentTimeMillis();

Will do it :)

like image 54
Tobias Ritzau Avatar answered Nov 07 '22 20:11

Tobias Ritzau


Use Calendar#getTimeInMillis:

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
long time = cal.getTimeInMillis();
like image 20
João Silva Avatar answered Nov 07 '22 19:11

João Silva