如何在 Android 上创建 Unix 时间戳?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10177552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:45:35  来源:igfitidea点击:

How do I create a Unix timestamp on Android?

androidunix-timestamp

提问by iamlukeyb

How do I create a Unix timestamp on Android?

如何在 Android 上创建 Unix 时间戳?

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

我想在 URL 的末尾创建一个带有 Unix 时间戳的 URL 发布请求。

回答by Nesim Razon

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

回答by Aleks G

It's quite simple:

这很简单:

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

回答by Deepak Shukla

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