方法:TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT);
获取的值如GMT+08:00,GMT-04:00,EDT
另附:
国家码查询网址:http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
时区查询网址:https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
说明:
参加源码TimeZone.java
public final String getDisplayName() {
return getDisplayName(false, LONG, Locale.getDefault());
}
public final String getDisplayName(Locale locale) {
return getDisplayName(false, LONG, locale);
}
public final String getDisplayName(boolean daylightTime, int style) {
return getDisplayName(daylightTime, style, Locale.getDefault());
}
/**
* Returns the {@link #SHORT short} or {@link #LONG long} name of this time
* zone with either standard or daylight time, as written in {@code locale}.
* If the name is not available, the result is in the format
* {@code GMT[+-]hh:mm}.
*
* @param daylightTime true for daylight time, false for standard time.
* @param style either {@link TimeZone#LONG} or {@link TimeZone#SHORT}.
* @param locale the display locale.
*/
public String getDisplayName(boolean daylightTime, int style, Locale locale) {
if (style != SHORT && style != LONG) {
throw new IllegalArgumentException("Bad style: " + style);
}
String[][] zoneStrings = TimeZoneNames.getZoneStrings(locale);
String result = TimeZoneNames.getDisplayName(zoneStrings, getID(), daylightTime, style);
if (result != null) {
return result;
}
// If we get here, it's because icu4c has nothing for us. Most commonly, this is in the
// case of short names. For Pacific/Fiji, for example, icu4c has nothing better to offer
// than "GMT+12:00". Why do we re-do this work ourselves? Because we have up-to-date
// time zone transition data, which icu4c _doesn't_ use --- it uses its own baked-in copy,
// which only gets updated when we update icu4c. http://b/7955614 and http://b/8026776.
// TODO: should we generate these once, in TimeZoneNames.getDisplayName? Revisit when we
// upgrade to icu4c 50 and rewrite the underlying native code. See also the
// "element[j] != null" check in SimpleDateFormat.parseTimeZone, and the extra work in
// DateFormatSymbols.getZoneStrings.
int offsetMillis = getRawOffset();
if (daylightTime) {
offsetMillis += getDSTSavings();
}
return createGmtOffsetString(true /* includeGmt */, true /* includeMinuteSeparator */,
offsetMillis);
}
public int getDSTSavings() {
return useDaylightTime() ? 3600000 : 0;
}
/**
* Returns the offset in milliseconds from UTC of this time zone's standard
* time.
*/
public abstract int getRawOffset();
Python 调用datetime或者time获取时间的时候以及时间转换,最好设置一下时区 否则会出现相差8个小时的情况
在使用调用datetime或者time获取时间的时候以及时间转换,最好设置一下时区, 因为不同机器设置的时区不同,获取的时间可能就不对,正好我们使用的这两个服务器使用的都是东八区,所以没有问题,设置方 ...
MTK Android中设置默认时区
设置默认时区 PRODUCT_PROPERTY_OVERRIDES += \ persist.sys.timezone=Asia/Shanghai\ 注:搜索“persist.sys.timezone ...
Android Permissions管理之用户拒绝授权
Android Permissions管理之用户拒绝授权,在Marshmallow之前的安卓版本,应用的权限只需要注册一下,应用就会获取到,在Marshmallow之后,为了安全,全新的权限模型出现, ...
android中获取root权限的方法以及原理(转)
一. 概述 本文介绍了android中获取root权限的方法以及原理,让大家对android 玩家中常说的“越狱”有一个更深层次的认识. 二. Root 的介绍 1. Root 的目的 可以让我们拥有 ...
Android中获取系统上安装的APP信息
Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:00000099 EndFragment:00003259 Android中获取系统上安装的APP信 ...
Android中获取正在运行的服务-------ActivityManager.RunningServiceInfo的使用
关于PackageManager和ActivityManager的使用 ,自己也写了一些DEMO 了,基本上写的线路参考了Settings模块下的 应用程序,大家如果真正的有所兴趣,建议大家看看源码, ...
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(22)-为用户设置角色
ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇) (1):框架搭建 (2):数据库访问层的设计Demo (3):面向接口编程 (4 ):业务逻辑层的封装 ...
使用腾讯开发平台获取QQ用户数据资料
Tips:本篇博客将教你如何使用腾讯开发平台获取QQ用户资料 ----------------------------------- ...
第七篇 :微信公众平台开发实战Java版之如何获取微信用户基本信息
在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的.对于不同公众号,同一用户的openid不同). 公众号可通过本接口来根据O ...
随机推荐
mssqlserver 分日志(日志文件过大)
ALTER DATABASE HexStudyDB3Reader SET RECOVERY SIMPLE WITH NO_WAIT ALTER DATABASE HexStudyDB3Reader S ...
hdu 5351 规律+大数
题目大意:定义了一种fib字符串,问第n个fib串的前m个字母前后相等串的最大长度,大约就是这样的 其实主要读完题意的时候并没有思路,但是列几个fib字符串就会发现,除了fib1以外,所有串的前面都是 ...
Centos如何设置静态IP地址,LINUX怎么修改IP地址
1.登陆连接centos系统,输入 ifconfig 可以查看到当前本机的IP地址信息 2.临时设置IP地址: 输入 ifconfig eth0 (默认是第一个网卡) 后面接IP地址, 网络掩码和 网 ...
HDOJ 1312 (POJ 1979) Red and Black
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...
.NET插件技术-应用程序热升级
今天说一说.NET 中的插件技术,即 应用程序热升级.在很多情况下.我们希望用户对应用程序的升级是无感知的,并且尽可能不打断用户操作的. 虽然在Web 或者 WebAPI上,由于多点的存在可以逐个停用 ...
Java 高级开发必修知识---反射
Class类的使用 1) 在面向对象的世界里,万事万物皆对象 A. Java语言中,普通数据类型,静态成员不是对象,其他皆对象 B. 每一个类也是对象 C. 类是java.lang.Class类的实例 ...
Eclipse反编译插件的安装
步骤: 1.已经安装了Eclipse,如我的Eclipse目录:C:\Programs\JAVA\eclipse 2.反编译插件包:eclipse 反编译插件 jad 3.3.0.zip 3.解压反编 ...
H5页面在微信中禁止下拉露出网页
H5页面在微信中禁止默认事件的执行,js添加代码 $(function () { /************微信h5页面禁止下拉露出网页来**************/ $('body').on('t ...
Python中调用设置环境变量的bat
工作中用到一个python脚本,自动化运行某目录下的多个vc工程代码. 编译工程代码的命令如下,直接运行会失败,系统找不到devenv,我们需要添加devenv.exe所在的目录到环境变量中. os. ...
【ajax】ajax异步实现用户注册验证
从前台到后台实现简单用户注册检查用户是否存在 1.编写domain public class User { private String username; private String passwo ...