|
|
灰常酷的小马驹 · QTableWidget ...· 1 年前 · |
|
|
果断的汤圆 · 如何使用SQL将同一列中的重复值合并为一个, ...· 2 年前 · |
|
|
干练的西红柿 · reactjs - ...· 3 年前 · |
|
|
帅气的柑橘 · angular - Typescript ...· 3 年前 · |
|
|
咆哮的书签 · 用户对问题“Android Studio ...· 3 年前 · |
获取当前UTC时间的函数是什么?我试过使用System.getCurrentTime,但我得到了设备的当前日期和时间。
谢谢
System.currentTimeMillis()
会提供自1970年1月1日00:00:00UTC以来的毫秒数。您看到本地时间的原因可能是因为您在使用
Date
实例之前将其转换为字符串。您可以在任何时区使用
DateFormat
s将
Date
%s转换为
String
%s:
DateFormat df = DateFormat.getTimeInstance();
df.setTimeZone(TimeZone.getTimeZone("gmt"));
String gmtTime = df.format(new Date());
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2023 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号: 粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
扫码关注腾讯云开发者
领取腾讯云代金券