Comparing ThreeTen backport to JSR-310

2019-03-27 20:00发布

问题:

For some reasons, we can't use java 8 right now - we're still stuck at java 7.
However, I'd like to use the new JSR-310 date/time APIs right now, using the official backport ThreeTen.

Its homepage states:

The backport is NOT an implementation of JSR-310, as that would require 
jumping through lots of unnecessary hoops. Instead, this is a simple backport
intended to allow users to quickly use the JSR-310 API on Java SE 6 and 7.

Questions:

  1. What are your experience with ThreeTen? Are there some drawbacks?

  2. How compatible is this project compared to the official JSR-310 implementations?

  3. How much effort is required to migrate from ThreeTen to an official java 8 implementation?

  4. Is it worth to migrate now to ThreeTen and later to JSR-310 - or should someone wait until java 8 can be used, hencing skipping ThreeTen?

回答1:

See this blog post.

ThreeTen-Backport is a solid backport consisting of equivalent code for the main API (though not so good for non-ISO calendar systems). To convert to Java 8 java.time requires changing the package name, and altering some constants to be method references.

I would not advise migrating from Joda-Time to ThreeTen-Backport, but do advise migrating from Joda-Time to Java 8 java.time.