How do I create a Unix timestamp on Android?

2019-03-11 14:31发布

问题:

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.

回答1:

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


回答2:

It's quite simple:

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