How do I create a Unix timestamp on Android?

AndroidUnix Timestamp

Android Problem Overview


How do I create a Unix timestamp on Android?

I want to create a URL post request with a Unix timestamp on the end of the url.

Android Solutions


Solution 1 - Android

 long unixTime = System.currentTimeMillis() / 1000L;

Solution 2 - Android

It's quite simple:

long timestamp = Calendar.getInstance().getTime() / 1000;

Solution 3 - Android

long timeStamp = Calender.getInstance().getTime() / 1000L ;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioniamlukeybView Question on Stackoverflow
Solution 1 - AndroidNesim RazonView Answer on Stackoverflow
Solution 2 - AndroidAleks GView Answer on Stackoverflow
Solution 3 - AndroidDeepak ShuklaView Answer on Stackoverflow