从互联网获取实际时间?

问题描述:

如果更改设备时间,如何以编程方式获取当前(实际)时间或网络运营商的时间

How to get 'current(actual) time' or 'network operator's time' programmatically if device time is changed ?

I' m尝试通过 LocationManager类的'getLastKnownLocation'方法获取当前时间。但这给出了最后的定位时间,但我需要当前时间。

I'm trying to get current time through 'getLastKnownLocation' method of 'LocationManager' class. But it gives last location time, but I need current time.

有人可以告诉我有关从互联网获取实际时间的正确方法的提示吗?

Can anyone tell me a clue about the correct way to get actual time from internet ?


  • 如果可能的话,不使用任何外部库。

预先感谢。

您可以使用地名 http://www.geonames.org/login提供的rest full api。 >为此将需要纬度和经度

You can use a rest full api provided by geo names http://www.geonames.org/login it will require lat and long for this purpose for example

http://api.geonames.org/timezoneJSON?lat=51.5034070&lng=-0.1275920&username=您的用户名