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.
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.
It's quite simple:
long timestamp = Calendar.getInstance().getTime() / 1000; System.currentTimeMillis() / 1000L ? (It looks less efficient to me - unless I am missing something?)myCalendar.getTimeInMillis() / 1000Updated answer with Kotlin:
val unix = Calendar.getInstance().timeInMillis Calendar.getInstance().timeInMillis / 1000. Check the other answers.