时代Java,与您同行!
关注微信公众号,关注前沿技术,微信搜索:nowjava或时代Java,也可点击这里扫码关注
时代Java
首页
集册
文章
实例
项目
快讯
时代+
手册
下载
Jar查找
登录
注册
Java 了解ZoneId的时间更改规则(ZoneRules)
Java 了解ZoneId的时间更改规则(ZoneRules)
欢马劈雪
工程师 (已认证)
原创分享签约作者
发表于
实例源码
订阅
390
查看 / 运行 实例源码
了解ZoneId的时间更改规则(ZoneRules)
实例源码:
源代码:
执行
执行中...
import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset;// 来自 时 代 Java 公 众 号 - nowjava.com import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; import java.util.List; public class Main { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); System.out.println("Current Date Time: " + now); ZoneId fixedZoneId = ZoneId.of("+06:00"); ZoneId bdDhaka = ZoneId.of("Asia/Dhaka"); ZoneId usChicago = ZoneId.of("America/Chicago"); // Print some zone rules for ZoneIds printDetails(fixedZoneId, now); printDetails(bdDhaka, now); printDetails(usChicago, now); } /* from n o w j a v a . c o m */ public static void printDetails(ZoneId zoneId, LocalDateTime now) { System.out.println("Zone ID: " + zoneId.getId()); ZoneRules rules = zoneId.getRules(); boolean isFixedOffset = rules.isFixedOffset(); System.out.println("isFixedOffset(): " + isFixedOffset); /**代码未完, 请加载全部代码(NowJava.com).**/
编辑/阅读全部代码
执行结果:
Current Date Time: 2020-03-25T16:51:26.844
Zone ID: +06:00
isFixedOffset(): true
Zone offset: +06:00
[]
Zone ID: Asia/Dhaka
isFixedOffset(): false
Zone offset: +06:00
[Transition[Overlap at 1890-01-01T00:00+06:01:40 to +05:53:20], Transition[Gap at 1941-10-01T00:00+05:53:20 to +06:30], Transition[Overlap at 1942-05-15T00:00+06:30 to +05:30], Transition[Gap at 1942-09-01T00:00+05:30 to +06:30], Transition[Overlap at 1951-09-30T00:00+06:30 to +06:00], Transition[Gap at 2009-06-19T23:00+06:00 to +07:00], Transition[Overlap at 2010-01-01T00:00+07:00 to +06:00]]
Zone ID: America/Chicago
isFixedOffset(): false
Zone offset: -05:00
[Transition[Overlap at 1883-11-18T12:09:24-05:50:36 to -06:00], Transition[Gap at 1918-03-31T02:00-06:00 to -05:00], Transition[Overlap at 1918-10-27T02:00-05:00 to -06:00], Transition[Gap at 1919-03-30T02:00-06:00 to -05:00], Transition[Overlap at 1919-10-26T02:00-05:00 to -06:00], Transition[Gap at 1920-06-13T02:00-06:00 to -05:00], Transition[Overlap at 1920-10-31T02:00-05:00 to -06:00], Transition[Gap at 1921-03-27T02:00-06:00 to -05:00], Transition[Overlap at 1921-10-30T02:00-05:00 to -06:00], Transition[Gap at 1922-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1922-09-24T02:00-05:00 to -06:00], Transition[Gap at 1923-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1923-09-30T02:00-05:00 to -06:00], Transition[Gap at 1924-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1924-09-28T02:00-05:00 to -06:00], Transition[Gap at 1925-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1925-09-27T02:00-05:00 to -06:00], Transition[Gap at 1926-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1926-09-26T02:00-05:00 to -06:00], Transition[Gap at 1927-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1927-09-25T02:00-05:00 to -06:00], Transition[Gap at 1928-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1928-09-30T02:00-05:00 to -06:00], Transition[Gap at 1929-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1929-09-29T02:00-05:00 to -06:00], Transition[Gap at 1930-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1930-09-28T02:00-05:00 to -06:00], Transition[Gap at 1931-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1931-09-27T02:00-05:00 to -06:00], Transition[Gap at 1932-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1932-09-25T02:00-05:00 to -06:00], Transition[Gap at 1933-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1933-09-24T02:00-05:00 to -06:00], Transition[Gap at 1934-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1934-09-30T02:00-05:00 to -06:00], Transition[Gap at 1935-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1935-09-29T02:00-05:00 to -06:00], Transition[Gap at 1936-03-01T02:00-06:00 to -05:00], Transition[Overlap at 1936-11-15T02:00-05:00 to -06:00], Transition[Gap at 1937-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1937-09-26T02:00-05:00 to -06:00], Transition[Gap at 1938-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1938-09-25T02:00-05:00 to -06:00], Transition[Gap at 1939-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1939-09-24T02:00-05:00 to -06:00], Transition[Gap at 1940-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1940-09-29T02:00-05:00 to -06:00], Transition[Gap at 1941-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1941-09-28T02:00-05:00 to -06:00], Transition[Gap at 1942-02-09T02:00-06:00 to -05:00], Transition[Overlap at 1945-09-30T02:00-05:00 to -06:00], Transition[Gap at 1946-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1946-09-29T02:00-05:00 to -06:00], Transition[Gap at 1947-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1947-09-28T02:00-05:00 to -06:00], Transition[Gap at 1948-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1948-09-26T02:00-05:00 to -06:00], Transition[Gap at 1949-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1949-09-25T02:00-05:00 to -06:00], Transition[Gap at 1950-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1950-09-24T02:00-05:00 to -06:00], Transition[Gap at 1951-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1951-09-30T02:00-05:00 to -06:00], Transition[Gap at 1952-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1952-09-28T02:00-05:00 to -06:00], Transition[Gap at 1953-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1953-09-27T02:00-05:00 to -06:00], Transition[Gap at 1954-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1954-09-26T02:00-05:00 to -06:00], Transition[Gap at 1955-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1955-10-30T02:00-05:00 to -06:00], Transition[Gap at 1956-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1956-10-28T02:00-05:00 to -06:00], Transition[Gap at 1957-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1957-10-27T02:00-05:00 to -06:00], Transition[Gap at 1958-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1958-10-26T02:00-05:00 to -06:00], Transition[Gap at 1959-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1959-10-25T02:00-05:00 to -06:00], Transition[Gap at 1960-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1960-10-30T02:00-05:00 to -06:00], Transition[Gap at 1961-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1961-10-29T02:00-05:00 to -06:00], Transition[Gap at 1962-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1962-10-28T02:00-05:00 to -06:00], Transition[Gap at 1963-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1963-10-27T02:00-05:00 to -06:00], Transition[Gap at 1964-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1964-10-25T02:00-05:00 to -06:00], Transition[Gap at 1965-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1965-10-31T02:00-05:00 to -06:00], Transition[Gap at 1966-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1966-10-30T02:00-05:00 to -06:00], Transition[Gap at 1967-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1967-10-29T02:00-05:00 to -06:00], Transition[Gap at 1968-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1968-10-27T02:00-05:00 to -06:00], Transition[Gap at 1969-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1969-10-26T02:00-05:00 to -06:00], Transition[Gap at 1970-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1970-10-25T02:00-05:00 to -06:00], Transition[Gap at 1971-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1971-10-31T02:00-05:00 to -06:00], Transition[Gap at 1972-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1972-10-29T02:00-05:00 to -06:00], Transition[Gap at 1973-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1973-10-28T02:00-05:00 to -06:00], Transition[Gap at 1974-01-06T02:00-06:00 to -05:00], Transition[Overlap at 1974-10-27T02:00-05:00 to -06:00], Transition[Gap at 1975-02-23T02:00-06:00 to -05:00], Transition[Overlap at 1975-10-26T02:00-05:00 to -06:00], Transition[Gap at 1976-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1976-10-31T02:00-05:00 to -06:00], Transition[Gap at 1977-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1977-10-30T02:00-05:00 to -06:00], Transition[Gap at 1978-04-30T02:00-06:00 to -05:00], Transition[Overlap at 1978-10-29T02:00-05:00 to -06:00], Transition[Gap at 1979-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1979-10-28T02:00-05:00 to -06:00], Transition[Gap at 1980-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1980-10-26T02:00-05:00 to -06:00], Transition[Gap at 1981-04-26T02:00-06:00 to -05:00], Transition[Overlap at 1981-10-25T02:00-05:00 to -06:00], Transition[Gap at 1982-04-25T02:00-06:00 to -05:00], Transition[Overlap at 1982-10-31T02:00-05:00 to -06:00], Transition[Gap at 1983-04-24T02:00-06:00 to -05:00], Transition[Overlap at 1983-10-30T02:00-05:00 to -06:00], Transition[Gap at 1984-04-29T02:00-06:00 to -05:00], Transition[Overlap at 1984-10-28T02:00-05:00 to -06:00], Transition[Gap at 1985-04-28T02:00-06:00 to -05:00], Transition[Overlap at 1985-10-27T02:00-05:00 to -06:00], Transition[Gap at 1986-04-27T02:00-06:00 to -05:00], Transition[Overlap at 1986-10-26T02:00-05:00 to -06:00], Transition[Gap at 1987-04-05T02:00-06:00 to -05:00], Transition[Overlap at 1987-10-25T02:00-05:00 to -06:00], Transition[Gap at 1988-04-03T02:00-06:00 to -05:00], Transition[Overlap at 1988-10-30T02:00-05:00 to -06:00], Transition[Gap at 1989-04-02T02:00-06:00 to -05:00], Transition[Overlap at 1989-10-29T02:00-05:00 to -06:00], Transition[Gap at 1990-04-01T02:00-06:00 to -05:00], Transition[Overlap at 1990-10-28T02:00-05:00 to -06:00], Transition[Gap at 1991-04-07T02:00-06:00 to -05:00], Transition[Overlap at 1991-10-27T02:00-05:00 to -06:00], Transition[Gap at 1992-04-05T02:00-06:00 to -05:00], Transition[Overlap at 1992-10-25T02:00-05:00 to -06:00], Transition[Gap at 1993-04-04T02:00-06:00 to -05:00], Transition[Overlap at 1993-10-31T02:00-05:00 to -06:00], Transition[Gap at 1994-04-03T02:00-06:00 to -05:00], Transition[Overlap at 1994-10-30T02:00-05:00 to -06:00], Transition[Gap at 1995-04-02T02:00-06:00 to -05:00], Transition[Overlap at 1995-10-29T02:00-05:00 to -06:00], Transition[Gap at 1996-04-07T02:00-06:00 to -05:00], Transition[Overlap at 1996-10-27T02:00-05:00 to -06:00], Transition[Gap at 1997-04-06T02:00-06:00 to -05:00], Transition[Overlap at 1997-10-26T02:00-05:00 to -06:00], Transition[Gap at 1998-04-05T02:00-06:00 to -05:00], Transition[Overlap at 1998-10-25T02:00-05:00 to -06:00], Transition[Gap at 1999-04-04T02:00-06:00 to -05:00], Transition[Overlap at 1999-10-31T02:00-05:00 to -06:00], Transition[Gap at 2000-04-02T02:00-06:00 to -05:00], Transition[Overlap at 2000-10-29T02:00-05:00 to -06:00], Transition[Gap at 2001-04-01T02:00-06:00 to -05:00], Transition[Overlap at 2001-10-28T02:00-05:00 to -06:00], Transition[Gap at 2002-04-07T02:00-06:00 to -05:00], Transition[Overlap at 2002-10-27T02:00-05:00 to -06:00], Transition[Gap at 2003-04-06T02:00-06:00 to -05:00], Transition[Overlap at 2003-10-26T02:00-05:00 to -06:00], Transition[Gap at 2004-04-04T02:00-06:00 to -05:00], Transition[Overlap at 2004-10-31T02:00-05:00 to -06:00], Transition[Gap at 2005-04-03T02:00-06:00 to -05:00], Transition[Overlap at 2005-10-30T02:00-05:00 to -06:00], Transition[Gap at 2006-04-02T02:00-06:00 to -05:00], Transition[Overlap at 2006-10-29T02:00-05:00 to -06:00], Transition[Gap at 2007-03-11T02:00-06:00 to -05:00], Transition[Overlap at 2007-11-04T02:00-05:00 to -06:00], Transition[Gap at 2008-03-09T02:00-06:00 to -05:00], Transition[Overlap at 2008-11-02T02:00-05:00 to -06:00]]
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。
编辑于
2020-03-26 09:23:27
2020-03-26 09:23:27
分享
分享文章到朋友圈
分享文章到 QQ
分享文章到微博
复制文章链接到剪贴板
扫描二维码
关注时代Java
实例源码
实例源码
订阅
订阅专栏
Java 判断文件是否为文本文件及获取文件编码格式的方法实例
bootstrap 实例演示下拉菜单(Dropdown)插件用法。
HashSet、LinkedHashSet、TreeSet类存储元素的自动排序规则实例测试
html css 对于 body和h1设置的实例源码
Java 获取在线网页的源代码
Java HashSet添加、迭代输出字符串的完整示例代码
Java 随机整数数组
html css 设置背景图片定位并且不平铺
扫描二维码
关注时代Java
返回顶部