how to get the number of seconds passed since 1970 for a date value?

前端 未结 2 464
执念已碎
执念已碎 2020-12-16 09:15

I have to an android application in which I need to convert the current date to the number of seconds passed since 1970.

What I am doing currently i

2条回答
  •  半阙折子戏
    2020-12-16 09:39

    //long currentTimeMillis ()-Returns the current time in milliseconds. 
    long millis = System.currentTimeMillis();
    
    //Divide millis by 1000 to get the number of seconds.
    long seconds = millis / 1000;
    

提交回复
热议问题