Skip to main content
This revision made October 25, 2011 23:14, by rwarburton

JSR 310 - new Date and Time API for Java

The LJC is getting involved in JSR-310 as we believe it's a vital technology for the Java language as software increasingly needs to be date, time and time zone aware in a safe immutable manner.

JSR in a Nutshell

Date and Calendar do not provide adequate functionality for day to day Java developers. JSR-310 addresses this with an implementation based on hard won lessons from JodaTime. For more information on JSR-310 please see the links below and this London Java Community Blog Post

LJC Goals

  1. To assist the threeten project in meeting the Technology Compatibility Kit (TCK) requirements of this JSR, a major milestone to having JSR-310 accepted as part of the Java language.
  2. Promote the ThreeTen implementation and provide pathways for members to get involved in either writing tests on the TCK project or getting involved in the ThreeTen implementation.

LJC Volunteers

We are looking for volunteers within the London Java Community and beyond to help us with our efforts, please contact either of the leads below if you are interested.

Proposed TCK Strategy

  1. Provide a method of running a TCK test suite against an arbitrary jar.
  2. Provide a method of specifying which TestNG tests are part of the TCK.
  3. Specify TestNG tests that are TCK appropriate from the current testsuite.
  4. Write any additional tests that are necessary in order to completely specify the API (It might be the case that this isn't necessary since you already have a lot of tests and test coverage)

Step 1

Source code is available at GitHub and we intend to continue development in the open. We've added a new ant target for testing TCK acceptance. So if you've compiled the latest version of the existing source code, then in order to run the TCK against it you would execute:

   ant -Dtck.implementation=build/threeten-0.6.3.jar tck

You can substitute any arbitrary jar as the 'tck.implementation' variable and it tests against the classes in that jar.

Step 2

We are using TestNG's group feature to specify what tests we want to use as part of the TCK. Currently the 'tck' ant target, only runs tests that are annotated as being part of the 'tck' group from the existing ThreeTen unit tests. So if you want to make a unit test part of tck acceptance you annotated it with:

   @Test(groups={"tck"})

We've currently annotated a single test with the annotation, but that's just to make sure that it works, rather than a comment on what is tck-appropriate or not.

Step 3

This step involves annotating all appropriate TestNG tests with the aforementioned group. We are yet to completely formalise the guidelines on what should be appropriate or not, here are some heuristics:

  • The public api is contained within the compiled jar at "build/threeten-*.*.*.jar". Any TCK tests should be only on methods that are publicly accessible. You will get a linktime error if you try to run the ant 'tck' command against a non-public api class, but you still need to be careful to not accidentally test implementation-specific methods.
  • Don't test methods that are private to classes.
  • Don't rely on invariants that encapsulated within classes.

There is a work-allocation table on Step 3 of the Volunteering page.

Some Legal information on submitting to the TCK

Please note that to submit work to the JCP you will need to have a JSPA countersigned by your employer for legal reasons. The LJC/JCP is currently working on providing some guidance on this, but until then the full detail is here.

Further links and information

Difference compared to previous revision
<span> @Test(groups={"tck"}) We've currently annotated a single test with the annotation, but that's just to make sure that it works, rather than a comment on what is tck-appropriate or not.<span style="text-decoration:underline;color:green"> </span> <span style="text-decoration:underline;color:green">'''Step 3''' </span>=JSR 310 - new Date and Time API for Java= The LJC is getting involved in JSR-310 as we believe it's a vital technology for the Java language as software increasingly needs to be date, time and time zone aware in a safe immutable manner. ... We've currently annotated a single test with the annotation, but that's just to make sure that it works, rather than a comment on what is tck-appropriate or not. Th<span style="text-decoration:line-through;color:red">e</span>Th<span style="text-decoration:underline;color:green">is</span> <span style="text-decoration:line-through;color:red">next </span>step<span style="text-decoration:line-through;color:red">s</span> <span style="text-decoration:line-through;color:red">w</span> step i<span style="text-decoration:underline;color:green">nvo</span>il<span style="text-decoration:line-through;color:red">l b</span>l<span style="text-decoration:underline;color:green">v</span>e<span style="text-decoration:underline;color:green">s</span>e <span style="text-decoration:line-through;color:red">to work o</span> <span style="text-decoration:underline;color:green">a</span>n<span style="text-decoration:line-through;color:red"> </span><span style="text-decoration:underline;color:green">not</span>a<span style="text-decoration:line-through;color:red">dd</span><span style="text-decoration:underline;color:green">t</span>ing <span style="text-decoration:line-through;color:red">the</span><span style="text-decoration:underline;color:green">all</span> a<span style="text-decoration:line-through;color:red">nn</span><span style="text-decoration:underline;color:green">ppr</span>o<span style="text-decoration:line-through;color:red">t</span><span style="text-decoration:underline;color:green">pri</span>at<span style="text-decoration:line-through;color:red">ion</span><span style="text-decoration:underline;color:green">e</span> <span style="text-decoration:underline;color:green">Tes</span> t<span style="text-decoration:line-through;color:red">o</span>t<span style="text-decoration:underline;color:green">NG</span> tests w<span style="text-decoration:line-through;color:red">h</span>i<span style="text-decoration:line-through;color:red">c</span> tests wi<span style="text-decoration:underline;color:green">t</span>h <span style="text-decoration:underline;color:green">the </span>a<span style="text-decoration:underline;color:green">fo</span>re<span style="text-decoration:underline;color:green">mentioned</span>h are <span style="text-decoration:line-through;color:red">TCK,</span> <span style="text-decoration:underline;color:green">group.</span><span style="text-decoration:underline;color:green"> We </span> a<span style="text-decoration:line-through;color:red">nd</span>a<span style="text-decoration:underline;color:green">re</span> <span style="text-decoration:underline;color:green">y</span>e<span style="text-decoration:underline;color:green">t to completely formal</span>i<span style="text-decoration:underline;color:green">se </span> eithe<span style="text-decoration:line-through;color:red">r</span> <span style="text-decoration:line-through;color:red">r</span>the <span style="text-decoration:underline;color:green">guid</span>e<span style="text-decoration:line-through;color:red">mov</span><span style="text-decoration:underline;color:green">l</span>in<span style="text-decoration:line-through;color:red">g</span><span style="text-decoration:underline;color:green">es</span> o<span style="text-decoration:line-through;color:red">r</span><span style="text-decoration:underline;color:green">n</span> <span style="text-decoration:underline;color:green">wh</span>a<span style="text-decoration:underline;color:green">t shoul</span>d<span style="text-decoration:underline;color:green"> be </span> adap<span style="text-decoration:line-through;color:red">t</span>ap<span style="text-decoration:underline;color:green">propr</span>i<span style="text-decoration:line-through;color:red">ng</span><span style="text-decoration:underline;color:green">ate</span> <span style="text-decoration:underline;color:green">or no</span>t<span style="text-decoration:underline;color:green">, h</span>e<span style="text-decoration:underline;color:green">re are </span>s<span style="text-decoration:underline;color:green">ome heuris</span>t<span style="text-decoration:underline;color:green">ic</span>s<span style="text-decoration:underline;color:green">: *</span> tests <span style="text-decoration:line-through;color:red">w</span> <span style="text-decoration:underline;color:green">T</span>h<span style="text-decoration:underline;color:green">e publ</span>hic<span style="text-decoration:line-through;color:red">h</span> a<span style="text-decoration:line-through;color:red">re</span>ic a<span style="text-decoration:underline;color:green">pi</span> i<span style="text-decoration:line-through;color:red">mpleme</span><span style="text-decoration:underline;color:green">s co</span>nta<span style="text-decoration:underline;color:green">ined wi</span>t<span style="text-decoration:underline;color:green">h</span>ntati<span style="text-decoration:line-through;color:red">o</span>n <span style="text-decoration:line-through;color:red">sp</span>in <span style="text-decoration:underline;color:green">th</span>e<span style="text-decoration:underline;color:green"> </span>c<span style="text-decoration:underline;color:green">omp</span>eci<span style="text-decoration:line-through;color:red">fic.</span>i<span style="text-decoration:underline;color:green">led</span> <span style="text-decoration:line-through;color:red">T</span><span style="text-decoration:underline;color:green">jar at "build/t</span>h<span style="text-decoration:line-through;color:red">e</span>hre<span style="text-decoration:underline;color:green">eten-*.*.*.jar".</span>re <span style="text-decoration:line-through;color:red">is</span> <span style="text-decoration:underline;color:green">A</span> n<span style="text-decoration:line-through;color:red">o</span>n<span style="text-decoration:underline;color:green">y</span> <span style="text-decoration:line-through;color:red">d</span><span style="text-decoration:underline;color:green">TCK tests sh</span>ou<span style="text-decoration:underline;color:green">ld </span>oub<span style="text-decoration:line-through;color:red">t</span>b<span style="text-decoration:underline;color:green">e</span> <span style="text-decoration:line-through;color:red">als</span> o<span style="text-decoration:underline;color:green">nly</span>o <span style="text-decoration:line-through;color:red">g</span>o<span style="text-decoration:line-through;color:red">i</span>n<span style="text-decoration:line-through;color:red">g</span> on <span style="text-decoration:underline;color:green">me</span>t<span style="text-decoration:underline;color:green">h</span>o<span style="text-decoration:underline;color:green">ds</span> to <span style="text-decoration:line-through;color:red">be </span> th<span style="text-decoration:underline;color:green">at ar</span>the <span style="text-decoration:line-through;color:red">sco</span>e p<span style="text-decoration:underline;color:green">ublicly acc</span>e<span style="text-decoration:underline;color:green">ssible.</span>pe <span style="text-decoration:line-through;color:red">t</span> <span style="text-decoration:underline;color:green"> Y</span>o<span style="text-decoration:underline;color:green">u</span>o w<span style="text-decoration:line-through;color:red">r</span>i<span style="text-decoration:line-through;color:red">t</span> wi<span style="text-decoration:underline;color:green">ll g</span>e<span style="text-decoration:underline;color:green">t</span> <span style="text-decoration:underline;color:green">a linkti</span>e m<span style="text-decoration:line-through;color:red">or</span>e <span style="text-decoration:line-through;color:red">t</span>e<span style="text-decoration:line-through;color:red">sts</span>me e<span style="text-decoration:underline;color:green">rror</span> <span style="text-decoration:underline;color:green">i</span>f<span style="text-decoration:underline;color:green"> y</span>o<span style="text-decoration:underline;color:green">u t</span>r<span style="text-decoration:underline;color:green">y</span> t<span style="text-decoration:underline;color:green">o run t</span> for the <span style="text-decoration:line-through;color:red">TCK. J</span>he a<span style="text-decoration:underline;color:green">nt 'tck' co</span>am<span style="text-decoration:line-through;color:red">e</span>m<span style="text-decoration:underline;color:green">mand again</span>s<span style="text-decoration:underline;color:green">t</span> a<span style="text-decoration:underline;color:green"> </span>s an<span style="text-decoration:line-through;color:red">d</span>n<span style="text-decoration:underline;color:green">on-public</span> <span style="text-decoration:line-through;color:red">R</span><span style="text-decoration:underline;color:green">ap</span>i<span style="text-decoration:underline;color:green"> </span>ic<span style="text-decoration:line-through;color:red">h</span>c<span style="text-decoration:underline;color:green">l</span>a<span style="text-decoration:line-through;color:red">rd</span><span style="text-decoration:underline;color:green">ss,</span> <span style="text-decoration:line-through;color:red">w</span><span style="text-decoration:underline;color:green">but you st</span>ill <span style="text-decoration:line-through;color:red">work</span><span style="text-decoration:underline;color:green">need</span> <span style="text-decoration:underline;color:green">t</span> o<span style="text-decoration:line-through;color:red">n</span>o <span style="text-decoration:underline;color:green">be </span>c<span style="text-decoration:underline;color:green">a</span> cre<span style="text-decoration:line-through;color:red">a</span>re<span style="text-decoration:underline;color:green">ful </span>t<span style="text-decoration:line-through;color:red">i</span><span style="text-decoration:underline;color:green">o </span>n<span style="text-decoration:line-through;color:red">g</span><span style="text-decoration:underline;color:green">ot</span> a<span style="text-decoration:line-through;color:red"> do</span>c<span style="text-decoration:line-through;color:red">um</span> ac<span style="text-decoration:underline;color:green">cid</span>ent<span style="text-decoration:underline;color:green">ally</span>ent t<span style="text-decoration:line-through;color:red">ha</span> t<span style="text-decoration:underline;color:green">es</span>t <span style="text-decoration:line-through;color:red">w</span>t i<span style="text-decoration:underline;color:green">mp</span>il<span style="text-decoration:line-through;color:red">l b</span>e<span style="text-decoration:line-through;color:red"> h</span>le<span style="text-decoration:underline;color:green">mentati</span>o<span style="text-decoration:underline;color:green">n-</span>os<span style="text-decoration:line-through;color:red">t</span>s<span style="text-decoration:underline;color:green">p</span>e<span style="text-decoration:underline;color:green">cific metho</span>d<span style="text-decoration:underline;color:green">s. *</span> <span style="text-decoration:underline;color:green">D</span>on<span style="text-decoration:underline;color:green">'t</span>ed on t<span style="text-decoration:line-through;color:red">hi</span> t<span style="text-decoration:underline;color:green">e</span>s<span style="text-decoration:underline;color:green">t</span>s <span style="text-decoration:line-through;color:red">Wiki </span> <span style="text-decoration:underline;color:green">me</span>t<span style="text-decoration:underline;color:green">h</span>o<span style="text-decoration:underline;color:green">ds</span>to t<span style="text-decoration:line-through;color:red">r</span> t<span style="text-decoration:underline;color:green">h</span>a<span style="text-decoration:line-through;color:red">ck</span><span style="text-decoration:underline;color:green">t</span> <span style="text-decoration:underline;color:green">are priva</span> t<span style="text-decoration:line-through;color:red">h</span>te t<span style="text-decoration:underline;color:green">o class</span>es<span style="text-decoration:underline;color:green">. * Don'</span>t<span style="text-decoration:underline;color:green"> rely on invariant</span>e tests that <span style="text-decoration:line-through;color:red">p</span>e<span style="text-decoration:line-through;color:red">o</span>s that e<span style="text-decoration:underline;color:green">nca</span>p<span style="text-decoration:underline;color:green">su</span>l<span style="text-decoration:underline;color:green">at</span>e<span style="text-decoration:underline;color:green">d</span> <span style="text-decoration:underline;color:green">within cl</span>a<span style="text-decoration:underline;color:green">sses. The</span>re <span style="text-decoration:underline;color:green">is a </span>work<span style="text-decoration:underline;color:green">-allocat</span>i<span style="text-decoration:underline;color:green">o</span>ple are workin<span style="text-decoration:line-through;color:red">g</span>n <span style="text-decoration:underline;color:green">table </span> on <span style="text-decoration:line-through;color:red">wi</span>on <span style="text-decoration:underline;color:green">S</span>t<span style="text-decoration:line-through;color:red">hin</span><span style="text-decoration:underline;color:green">ep</span> <span style="text-decoration:underline;color:green">3 of </span>the <span style="text-decoration:underline;color:green">[[JSR-310Volu</span>n<span style="text-decoration:underline;color:green">t</span> the ne<span style="text-decoration:line-through;color:red">x</span>e<span style="text-decoration:underline;color:green">ering|Volun</span>t<span style="text-decoration:line-through;color:red"> f</span>e<span style="text-decoration:line-through;color:red">w</span>te<span style="text-decoration:underline;color:green">ering]]</span> <span style="text-decoration:line-through;color:red">w</span><span style="text-decoration:underline;color:green">pag</span>e<span style="text-decoration:line-through;color:red">eks</span>. '''Some Legal information on submitting to the TCK''' <span>
 
 
Close
loading
Please Confirm
Close