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

Solution 1:

System.currentTimeMillis() gives you the number of milliseconds since the Unix epoch (January 1, 1970 00:00:00 UTC).

Divide it by 1000 to get the number of seconds.

Solution 2:

//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;