作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用此代码获取 android 设备的 timezone
TimeZone tz = TimeZone.getDefault();
String current_Time_Zone = (TimeZone.getTimeZone(tz.getID()).getDisplayName(
false, TimeZone.SHORT))
但它总是像“IST
”一样返回timezone
,但我想像这样GMT 获取
GMT
中的时区+7:00。
最佳答案
这可能会让您了解如何根据自己的喜好实现它:
Calendar mCalendar = new GregorianCalendar();
TimeZone mTimeZone = mCalendar.getTimeZone();
int mGMTOffset = mTimeZone.getRawOffset();
System.out.printf("GMT offset is %s hours", TimeUnit.HOURS.convert(mGMTOffset, TimeUnit.MILLISECONDS));
(时间单位是“java.util.concurrent.TimeUnit”)
关于android - 如何在 GMT 中获取时区偏移量(如 GMT+7 :00) from android device?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15068113/
我是一名优秀的程序员,十分优秀!