Skip to content
Advertisement

Android Get Current timestamp?

I want to get the current timestamp like that : 1320917972

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

Advertisement

Answer

The solution is :

Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement