【问题标题】:Android - Google Maps Timezone API - Milliseconds/UTCAndroid - 谷歌地图时区 API - 毫秒/UTC
【发布时间】:2017-01-11 03:24:17
【问题描述】:

我正在使用改造 2 来调用谷歌地图时区休息 API。这是我的应用提交的 URL:

https://maps.googleapis.com/maps/api/timezone/json?location=33.4556535,-117.634454&timestamp=1484098782775&key=密钥

时间戳来自 System.currentTimeMillis()

我从谷歌收到“无效请求”。进一步缩小范围表明唯一的问题是时间戳/毫秒。

Here is a version of timestamp that works:
1331161200

See above the version of timestamp that does not work (from System.currentTimeMillis() is: 1484098782775

“额外”的 2 位数字看起来很可疑?

总之,System.currentTimeMillis() 不是 Google 期望的正确纪元/时间戳/毫秒值吗?

提前感谢您的帮助。

【问题讨论】:

    标签: android google-maps datetime


    【解决方案1】:

    System.currentTimeMillis() 返回(来自the documentation)当前时间与 UTC 1970 年 1 月 1 日午夜之间的差异,以 毫秒 为单位。

    根据the documentation,Google Maps Time Zone API 预计 timestamp 参数自 UTC 1970 年 1 月 1 日午夜起的

    时间戳将所需时间指定为自 UTC 1970 年 1 月 1 日午夜以来的秒数

    因此,要解决您的问题,只需将返回的毫秒数从 System.currentTimeMillis() 转换为 secons 以将其用作您请求的 timestamp 参数。

    【讨论】:

    • 修复了它。非常感谢安东尼奥。感谢您的帮助。
    猜你喜欢
    • 2017-04-25
    • 2013-07-28
    • 1970-01-01
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    相关资源
    最近更新 更多