public class ParseUtcDateTimeStringTest { @Test public void testUtcStringToDate() { // "Z" at the end of the date time string is for UTC String utcDateStr = "2017-08-28T02:03:41.080Z"; System.out.println("====== testUtcStringToDate: " + utcDateStr); // Parse the utc datetime string to java.time.Instant - defaults formatter to DateTimeFormatter.ISO_INSTANT. Instant instant = Instant.parse(utcDateStr); System.out.println("Parsed instant in UTC: " + instant); // single quote around 'T' DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"); // convert to LocalDateTime with default time zone ZoneId defaultZone = ZoneOffset.systemDefault(); System.out.println("defaultZone: " + defaultZone); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.of(defaultZone.getId())); System.out.println("Converted localDateTime=" + localDateTime); // convert to ZonedDateTime - you cannot format an Instant, have to convert it to a formattable date time ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.of(defaultZone.getId())); System.out.println("Formatted zonedDateTime=" + formatter.format(zonedDateTime)); // get ZoneOffset and then ZoneRules ZoneOffset zoneOffset = zonedDateTime.getOffset(); System.out.println("zoneOffset: " + zonedDateTime.getOffset()); ZoneRules zoneRules = ZoneRules.of(zoneOffset); System.out.println("zoneRuels: " + zoneRules); // ZoneRules tells if it's daylight savings time... if (zoneRules.isDaylightSavings(instant)) { System.out.println("Auckland summer has daylight saving time, which is 13 hours ahead of UTC"); Assert.assertEquals("2017-08-28T15:03:41.080", formatter.format(zonedDateTime)); } else { System.out.println("Auckland has winter time 12 hours ahead of UTC"); Assert.assertEquals("2017-08-28T14:03:41.080", formatter.format(zonedDateTime)); } } }
- 浏览: 96043 次
文章分类
最新评论
-
jXee:
lgs0626 写道求源码,兄弟给共享下吧 "jee ...
jee6 学习笔记 4 - CRUD 2: View Details, Primefaces row selection -
lgs0626:
求源码,兄弟给共享下吧
jee6 学习笔记 4 - CRUD 2: View Details, Primefaces row selection
发表评论
-
净土初祖解说三心往生
2019-08-16 11:08 7。。。 三修心往生。如下文说。心有三种。一者诚心。诚谓实也。 ... -
沉默是金
2019-08-10 11:40 16与人相处,沉默是金。他不来问,一般来说你也不要主动去说。这里有 ... -
环境的欺骗性
2019-07-24 12:06 37看看周围,每个人似乎都很安详,甚至欢喜。因社会与工作需要,人们 ... -
死亡为什么是恐怖的?
2019-07-19 12:09 27如果你问一个人,你了 ... -
我是王打铁,愿做王打铁
2019-07-18 07:17 38一个人,不受点磨难, ... -
ActiveMQ and Spring JMS Framework Message Loss
2019-06-28 07:15 29Java Message Service (JMS) prov ... -
江河竞注而不流
2019-05-04 08:22 32可能你已经拥有了事业,女人,房子,车子,孩子,家庭...然而, ... -
实修安般念要点小结
2019-03-26 08:37 109最近读了一些关于“安 ... -
如何是四禅?
2019-03-22 17:31 489阿义耶萨那! 如是予摄粗食乳糜,得体力,离欲、离不善法,有寻、 ... -
楞伽经大慧菩萨赞佛偈
2019-02-04 07:38 100世间离生灭,犹如虚空华,智不得有无,而兴大悲心。 一切法如幻, ... -
人工智能与意识
2019-01-16 06:40 130人工智能在识别与判断等方面已经得到长足的发展,现在人们谈论意识 ... -
害怕让亲人失望
2019-01-09 05:48 88自己可以忍受很多,但害怕让自己的亲人失望。这本质上还是一种我见 ... -
唯心识观与真如实观
2018-12-24 10:08 103“若欲依一实境界修信 ... -
一实境界义
2018-12-24 09:47 92尔时,坚净信菩萨摩诃萨问地藏菩萨摩诃萨言:"云何开示 ... -
什么是情?情产生的过程?如何用心?
2018-12-10 09:24 108情,心有色想。修行人要知,名色缘六入,六入缘触,触缘想和受。所 ... -
真如本性与外道神我有什么区别?
2018-09-01 08:59 220大乘佛教提出的真如本性,也就是常住真心,它的特点是恒不变,同时 ... -
how to proxy to k8s web console
2018-06-28 07:16 525### how to access k8s web conso ... -
Call Stored Procedure with JPA 2.1
2018-06-27 10:57 613JPA 2.1 introduces APIs to call ... -
Send response and then process - async processing
2017-10-12 09:35 506If your request processing take ... -
Setup ApiKey in header with Swagger generated client code
2017-08-23 06:41 434@Value("${api.base.path} ...
相关推荐
About This Book, Implement concurrent applications using the Java 8 Concurrency API and its new componentsImprove the performance of your applications or process more data at the same time,...
近期服务器出现大量time_wait的TCP连接造成服务器连接数过多而最终导致tomcat假死状态。连接服务器查看连接数的时候提示如下。 [root@test apache-tomcat-7.0.53]# ...通过java API解决这个问题的路子就堵死了。
api(java.time) Lambda 表达式 默认方法 流 可选的 路口类型 Javascript Base64 编码和解码 字符串连接器 类型注释 JDBC 改进 暖身 创建目录 mkdir java8 转到java8目录并应用gradle init命令创建java项目 gradle ...
java8 源码 java8 java8 note and code example java8新特性 Stream Api Lambda 表达式 行为参数化 接口中的默认方法 Date Time Api Optional 类 Stream 和 Collection的区别 Stream 描述对数据的计算 Collection ...
onlyTest.java 对象传值示例 otherClass.java 从类的外部访问对象的成员 showInstVar.java 演示不同的对象拥有不同的成员变量 showMain.java 演示main方法访问本类成员 showMethod.java 演示如何定义一个方法体...
Fundamentals of the JavaMail API Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click ...
JAVA高级特性 1.静态导入:先举个离例子 。 import java.lang.Integer.parseInt; public class StaticImport { int x = parseInt("123"); System.out.println(x); } 这样的程序如果不在IDE 工具中输入,是很难...
Save time and money by making your Selenium tests 99% reliable Improve the stability of your test suite and your programing skills by following a step-by-step continuous improvement tutorial Who ...
The Selenium WebDriver 3.x Technology is an open source API available to test both Browser and Mobile applications. It is completely platform independent in that tests built for one browser or mobile ...
Set up Selenium Grid for faster and parallel running of tests, increasing test coverage and reducing test execution time for cross-browser testing Build extended Selenium WebDriver tests for ...
Set up Selenium Grid for faster and parallel running of tests, increasing test coverage and reducing test execution time for cross-browser testing Build extended Selenium WebDriver tests for ...
Using Java 8 Features with Selenium Exploring the Features of WebDriver Exploring Advanced Interactions of WebDriver Understanding WebDriver Events Exploring RemoteWebDriver Setting up Selenium ...
It is an API that augments Java with building blocks for defining and running simulations. The original SimJava was based on HASE++, a C++ simulation library. HASE++ was in turn based on SIM++. The ...
With a good plan on improvement while having a full time job as an Android Developer, he also spends a lot of time on the forum java-gaming.org learning and making contacts. He joined forces with a ...
$content = "test"; // 发送内容,不建议太长 $encode = "gb2312"; // 字符编码,可选参数 //可传 notify 或 ad , adcard,adfangchan,dxztd 五参数, notify: 表示通知类, ad: 表示106通道广告类,adcard: 表示卡...
- Jaxen - universal java xpath engine - runtime, required if you want to deserialize a Configuration to improve startup performance ant-junit-1.6.5.jar (1.6.5) - Ant junit support - buildtime ant-...
Debug HTTP API calls to a back-end and between back-ends, Easy to use, clean UI, and short ramp-up time. Not a proxy, no network issues! Doesn't change the browser's configuration for the proxy. Can ...
它允许您调用 rest API(当前生成 JSON)并在 logstash 事件中发送生成的 JSON。 这个插件背后的想法来自需要读取 springboot 指标端点,而不是配置 jmx 来监控我的 java 应用程序内存 / gc/ 等。 它是完全...
Approach 2 – Aggregate the results at query-time Writing the NetworkLogsMapper job Writing the mapper class Writing Driver Building the job Getting the data into HDFS Running the job Viewing ...
的 Android SDK 提供了在 Android 平台上使用 JaVa 语言进行 Android 应用开发必须的工具和 API 接口。 特性 • 应用程序框架 支持组件的重用与替换 • Dalvik Dalvik Dalvik Dalvik 虚拟机 专为移动设备优化 • ...