Android Get Current timestamp?

Rjaibi Mejdi picture Rjaibi Mejdi · Nov 10, 2011 · Viewed 314.2k times · Source

I want to get the current timestamp like that : 1320917972

int time = (int) (System.currentTimeMillis());
Timestamp tsTemp = new Timestamp(time);
String ts =  tsTemp.toString();

Answer

Rjaibi Mejdi picture Rjaibi Mejdi · Aug 12, 2014

The solution is :

Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();