获取纬度和纬度在android的时区? [英] Get TimeZone by lat and long in android?
问题描述
我需要lat,long的时区,因为我发现这篇文章很有帮助从经纬度获取时区。如此链接中所述,如果我使用 Google Api ,则其回复为
I need Time Zone by lat,long ,for that I have found this post helpful Get Time Zone From Lat Long. As described in this link if I use Google Api then its response is
{
"dstOffset" : 3600,
"rawOffset" : -18000,
"status" : "OK",
"timeZoneId" : "America/New_York",
"timeZoneName" : "Eastern Daylight Time"
}
但我的要求是,如果印度的时区是5:30,那么我需要它是5.5
或者如果任何国家时区是7:0然后是7.0。我的问题是我如何从lat中获得timezone,并且如上所述在自定义窗体中
but my requirement is that if India`s Time Zone is 5:30 then I need it to be 5.5 or if Any country time zone is 7:0 then 7.0. My question is how I get timezone from lat long also in custom form as specified above
推荐答案
这条线可以帮助您... ..
this line may help you.....
double zone = (responseObject.get("rawOffset").getAsInt() + responseObject.get("dstOffset").getAsInt()) / 3600.0;
从响应中获取rawOffset和dstOffset并添加它们,并将它们分为3600 ..... rawOffset是GMT + - 时区,秒数,dstOffset是夏时制偏移量,秒(如果一个国家有dst,它将是3600其他0)
get rawOffset and dstOffset from the response and add them, and divide them on 3600..... rawOffset is the GMT +- timezone in seconds and dstOffset is daylight saving offset in second (if a country is having dst it will be 3600 else 0)
这篇关于获取纬度和纬度在android的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!