有没有办法从接收到的回调中获取时区信息?
如果有其他方法,请提供相关信息!
void onLocationChanged(Location location)
利用从位置参数获取的时间信息
long Time = location.getTime();
如果有其他方法,请提供相关信息!
{"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}
您可以使用java.util.TimeZone调用TimeZone.getDefault()来获取有关当前时区的信息,例如:
java.util.TimeZone tz = java.util.TimeZone.getDefault();
Toast.makeText(context, tz.getDisplayName(), Toast.LENGTH_LONG).show();
TimeZone tz = TimeZone.getDefault();
System.out.println("TimeZone "+tz.getDisplayName(false, TimeZone.SHORT)+" Timezon id :: " + tz.getID());
输出
TimeZone GMT+09:30 Timezon id :: Australia/Darwin