Getting timezone in android

Is there a way to get the time zone from received callbacks

void onLocationChanged(Location location) 

using time information that can be obtained from a location parameter

 long Time = location.getTime(); 

Or, if there is another way, provide the information!

+7
android timezone datetime
source share
3 answers

You can use the web service provided by geonames.org. Set latitude and longitude to get time zone information.

http://ws.geonames.org/timezoneJSON?lat=47.01&lng=10.2 :

 {"time":"2010-07-24 18:35","countryName":"Austria","sunset":"2010-07-24 21:02","rawOffset":1,"dstOffset":2,"countryCode":"AT","gmtOffset":1,"lng":10.2,"sunrise":"2010-07-24 05:48","timezoneId":"Europe/Vienna","lat":47.01} 
+3
source share

You can use java.util.TimeZone to get information about the current time zone by calling TimeZone.getDefault (), for example:

 java.util.TimeZone tz = java.util.TimeZone.getDefault(); Toast.makeText(context, tz.getDisplayName(), Toast.LENGTH_LONG).show(); 
+2
source share
 TimeZone tz = TimeZone.getDefault(); System.out.println("TimeZone "+tz.getDisplayName(false, TimeZone.SHORT)+" Timezon id :: " + tz.getID()); 

Output

 TimeZone GMT+09:30 Timezon id :: Australia/Darwin 
0
source share

All Articles