Demo a bit JSR 310 Date and Time API

2010-12-23  来源:本站原创  分类:Java  人气:98 

Start with the official website to download the JSR 310 reference implementation: jsr-310-ri-0.6.3.jar, jsr-310-TZDB-all-0.6.3.jar

Then use Groovy to demo what

D:\downloads>set JAVA_OPTS=-Xbootclasspath/p:jsr-310-ri-0.6.3.jar;jsr-310-TZDB-all-0.6.3.jar

D:\downloads>\sdk\groovy-1.7.2\bin\groovysh
Groovy Shell (1.7.2, JVM: 1.6.0_23)
Type 'help' or '\h' for help.
-----------------------------------------------------------------------
groovy:000> import javax.time.*
===> [import javax.time.*]
groovy:000> import javax.time.calendar.*
===> [import javax.time.*, import javax.time.calendar.*]
groovy:000> london = TimeZone.of("Europe/London")
===> Europe/London
groovy:000> date1 = ZonedDateTime.of(1752, 9, 2, 0, 0, 0, 0, london)
===> 1752-09-02T00:00-00:01:15[Europe/London]
groovy:000> date2 = date1.plus(Period.ofDays(1).withHours(8))
===> 1752-09-03T08:00-00:01:15[Europe/London]
groovy:000> date2.toLocalDate()
===> 1752-09-03
groovy:000> eastern = TimeZone.of("US/Eastern")
===> US/Eastern
groovy:000> date3 = ZonedDateTime.of(1752, 9, 2, 0, 0, 0, 0, eastern)
===> 1752-09-02T00:00-04:56:02[US/Eastern]
groovy:000> date4 = date3.plus(Period.ofDays(1).withHours(4), ZoneResolvers.retainOffset())
===> 1752-09-03T04:00-04:56:02[US/Eastern]
groovy:000> quit

Before some of the dialogue:

t writes

klauszou I really came to talk about which languages have not seen a real full sound to write the date of the Gregorian calendar class so Every time I see a spade comes loaded to force in the class also wrote you with people who feel to laugh

klauszou m $ to say on this point is very interesting to know to write well, so simply put problems of the time period may have ruled out the www

rednaxelafx @ klauszou Java's new Date Time API (JSR 310) and perhaps the line? Seeking evaluation

klauszou not used, is not clear how specific, but you can be very simple to verify, first of all it has no location parameter, would certainly not perfect toka RT: @ rednaxelafx: @ klauszou Java's new Date Time API (JSR 310 ) may also work? Seeking evaluation

klauszou give a simple example, not all countries have also started using the Gregorian calendar, and historically, including the UK, countries like the United States until the 18th century began, and therefore the calculation of the Julian Gerry makeup set in 1752, and Calculation of the traditional European countries making it up in 1582. Assumed to be related to the time zone is more complex

rednaxelafx @ klauszou Well, that example I do not know how to verify the good. See that there are such API, seemingly advanced than the simple offset some http://is.gd/jiN76

klauszou. @ rednaxelafx authentication method is simple, the European makeup is October 4, 1582 began to make up for 10 days, the next day for the new calendar on October 15. United States or Britain, then from September 2, 1752 began to make up for 11 days, that the next day is a new calendar on September 14. Looked rough, this more than most are tricky, but should not be perfect.

klauszou. @ rednaxelafx'd calculated the relative time zone well, and several special circumstances are taken into account, but in relation to the issue of location should still have problems

So it seems the reference implementation of JSR 310 is considered comprehensive enough?

JSR 310 API to use up the whole feel is very smooth, two sets of time than the existing API JDK better Unfortunately, Oracle does not know when it will go into JDK. JDK7 mostly hopeless, JDK8 I am afraid ...

相关文章
  • Demo a bit JSR 310 Date and Time API 2010-12-23

    Start with the official website to download the JSR 310 reference implementation: jsr-310-ri-0.6.3.jar, jsr-310-TZDB-all-0.6.3.jar Then use Groovy to demo what D:\downloads>set JAVA_OPTS=-Xbootclasspath/p:jsr-310-ri-0.6.3.jar;jsr-310-TZDB-all-0.6.3.j

  • JavaOne 2010 impressions - Draft articles 2011-01-04

    Records wanted to focus on Beijing 2010 JavaOne knowledge, but unfortunately the Beijing Railway Station in San Francisco than the original shrink too much, do not feel very inadequate force of the original one way or another, so bring the JavaOne 20

  • Spring 4 增强了对Java 8.Java EE 7.REST 和HTML5的支持 2015-01-25

    几天之前Pivotal发布了Spring 4.0,这是自2009年之后发布的首个主要版本.新版本支持Java 8,支持使用Lambda的回调表达式.支持JSR 310日期和时间API以及参数名发现. 对Java EE 7 的支持包括:JMS 2.0.JTA 1.2.JPA 2.1.Bean验证1.1和JSR-236并发工具. Spring 4还改善了REST支持,提供了一个新的AsyncRestTemplate和HTML5/WebSocket与旧版本浏览器的集成. 如果你想要查看Spring 4

  • java date format handling Daquan Date format SimpleDateFormat 2010-03-29

    Java In the date format conversion /** * Convert java string .util.Date<br> * Support the format yyyy .MM.dd G 'at' hh:mm:ss z As '2002-1-1 AD at 22:10:59 PSD'<br> * yy/MM/dd HH:mm:ss As '2002/1/1 17:55:00'<br> * yy/MM/dd HH:mm:ss pm As

  • JSR specification Daquan 2010-07-24

    J2ME configuration specification ========= JSR 30 --- Connected Limited Device Configuration 1.0 http://jcp.org/en/jsr/detail?id=30 JSR 139 --- Connected Limited Device Configuration 1.1 http://jcp.org/en/jsr/detail?id=139 JSR 36 --- Connected Device

  • REST-based Web services: foundation 2011-05-24

    REST-based Web services: foundation Alex Rodriguez , software engineer, WSO2 Inc Description: Representational State Transfer (Representational State Transfer, REST) ​​in the Web area has been widely accepted, is based on SOAP and Web Services Descri

  • 你应该更新的Java知识之常用程序库(一) 2014-08-07

    在很多人眼中,Java已经是一门垂垂老矣的语言,但并不妨碍Java世界依然在前进.如果你曾离开Java,云游于其它世界,或是每日只在遗留代码中挣扎,或许是时候抬起头,看看老Java中的新东西. Guava 一句话,只要你做Java项目,就应该用Guava. guava是Google出品的一套Java核心库,在我看来,它甚至应该是JDK的一部分.作为一个Java程序员,如果你没抱怨过JDK的设计,只能说明一点,你写得程序还是太少.正是JDK设计不彰,才有了一些项目来补充JDK的不足.如果说老Jav

  • JavaOne 2013综述:Java 8是革命性的,Java回来了 2014-10-11

    JavaOne 2013已于近日在旧金山举行.9月22日,来自Oracle员工Peter Utzschneider.Nandini Ramani和Cameron Purdy的战略主题演讲拉开了此次庆典的序幕,活动持续到9月26日. 这是第十八次JavaOne大会,Java社区并没有显出放缓的迹象.Utzschneider告诉观众,Java仍然是世界第一的开发平台,并且Java用户组的数量以每年10%的速度增长. Java的未来 Ramani探讨了Java的现状以及Java如何有若干不同的SDK,

  • Java 8中时间 API 初探 2013-07-21

    Java 8目前已经开始进入大众的视线,其中笔者在写本文之前,留意到其中Java 8预览版中将会出现新的关于日期和时间的API(遵守JSR 310规范).在本系列文章中,将对这些新的API进行举例说明.首先在本文中,将先介绍以下几个:Instant,LocalDate,LocalTime 和 LocalDateTime.首先看看 Instant 对象的使用方法: Instant (java.time.Instant) 可能 java.time 包中最容易开始学习的内容就是 Instant 这个类

  • Java 8中的时间api初探1 2013-07-24

    本文是本人翻译作品,原文发表在:http://developer.51cto.com/art/201307/403828.htm Java 8目前已经开始进入大众的视线,其中笔者在写本文之前,留意到其中Java 8预览版中将会出现新的关于日期和时间的API(遵守JSR 310规范).在本系列文章中,将对这些新的API进行举例说明.首先在本文中,将先介绍以下几个:Instant,LocalDate,LocalTime和LocalDateTime. Java 8目前已经开始进入大众的视线,其中笔者在

  • Java 8新特性探究(七)深入解析日期和时间-JSR310 2014-01-17

    博客一个月没更新了,这次给大家讲下java8时间与日期API. 众所周知,日期是商业逻辑计算一个关键的部分,任何企业应用程序都需要处理时间问题.应用程序需要知道当前的时间点和下一个时间点,有时它们还必须计算这两个时间点之间的路径.但java之前的日期做法太令人恶心了,我们先来吐槽一下 吐槽java.util.Date跟Calendar Tiago Fernandez做过一次投票,选举最烂的JAVA API,排第一的EJB2.X,第二的就是日期API. 槽点一 最开始的时候,Date既要承载日期信

  • Struts2 Notes - 10 custom type converter 2010-03-29

    package struts2.demo.action; import java.util.Date; public class DateAction { private Date birthday; public String execute(){ return "success"; } public void setBirthday(Date birthday) { System.out.println(birthday); this.birthday = birthday; }

  • JDK1.6.0 Illustration and code examples of new features 2010-03-31

    JDK6.0 release for some time, the new JDK, there are many new features, I went online to gather a bit, are listed below and we will study together. 1. Desktop and SystemTray. In JDK6 in, AWT added two new categories: Desktop and SystemTray, the forme

  • Under the Edit in intellij idea jspx files (change) 2010-04-01

    Under the Edit in intellij idea jspx files (change) JSP 2.0 jspx is an important function in the upgrade, jspx syntax is actually written in jsp to xml file. We know that jsp format, which is an important feature include "<%" statement breaks

  • Java rules engine and its API (JSR-94) 2010-04-09

    Java rules engine and its API (JSR-94) Levels: July 1, 2005 In this paper, Java rules engine and its API (JSR-94) and related implementation to do a more detailed description of its architecture and API applications are more detailed descriptions, an

  • Spring to learn a: FirstDemo 2010-09-06

    IDE: MyEclipse 8.6, JRE1.6 First, create a new Java Project, Project name: SpringStudy. Right then select MyEclipse-> Add Spring Capabilities Second, in the src directory, add the Log4j configuration file log4j.properties, reference configuration as

  • [Change] JDK1.6.0 Illustration and code examples of new features 2010-09-15

    Original Address: http://www.blogjava.net/richardeee/archive/2007/02/09/98968.html JDK6.0 release for some time, the new JDK, there are many new features, I went online to gather a bit, are listed below and we will study together. 1. Desktop and Syst

  • In SpringMVC environments SimpleFramework 2010-12-25

    The case focuses on how to integrate with Spring Web MVC framework SimpleFramework, an example demonstrates SimpleFramework tree component (Tree) and the server side of the Spring Web MVC framework for the integration process. Prerequisites This tuto

  • Servlet3.0 combat: Asynchronous Servlet and Comet-style applications 2011-10-04

    Outline With Java EE 6 system, an important member of the JSR 315 specification, the Servlet API the latest version from the 2.5 upgrade to 3.0, which is nearly 10 years, Servlet version of the biggest upgrade, the upgrade introduced a number of item

  • PHP日志扩展 SeasLog 2014-02-07

    SeasLog 网站 : http://neeke.github.io/SeasLog/ SeasLog Yet a log extension for PHP.A effective,fast,stable log extension for PHP @author Chitao.Gao [[email protected]] 为什么使用SeasLog log日志,通常是系统或软件.应用的运行记录.通过log的分析,可以方便用户了解系统或软件.应用的运行情况:如果你的应用log足够丰富,也可以