8

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?

assylias
  • 321,522
  • 82
  • 660
  • 783
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
  • 4
    One thing you won't get is the brdidge from the Date API - for example in Java 8 you can write `new Date(...).toInstant()` but you won't have that in Java 7. This may or may not be an issue for your use case. – assylias Mar 30 '15 at 12:51
  • I guess answers to questions 3/4 would heavily depend on **how** you make use of Three Ten backport API. I guess: if you are careful; and try to understand the consequences of your actions; efforts for q3 should be minimal. – GhostCat Mar 30 '15 at 12:57
  • Use or Wait, or - third alternative - **JODA** date/time. As the old classes are best forgotten, date/time classes can be unittested, you may go for the backport + unit tests + unit tests under Java 8. That is easier, more pleasant than a later rewrite. On the other hand is it worthwhile? – Joop Eggen Mar 30 '15 at 13:00
  • 2
    @JoopEggen If they plan to move on to the new Java Time API at some stage, using threetenbp will make an easier transition than using Joda. – assylias Mar 30 '15 at 13:01
  • @assylias I agree, and a couple of unit tests should assure that functions do what one thought. However if Java 8 is more of an intention than pinned down, JODA might be a temporary solution. – Joop Eggen Mar 30 '15 at 13:10
  • 1
    ThreeTen has some issues with certain locales such as Korea. It crashes on startup. If you do not run in a lot of other countries this might not be a concern to you. Right now I am looking for a ThreeTen replacement due to the startup crash that keeps occurring with some of our international users. If they updated the locale table this would probably go away. – Kevin Sep 26 '17 at 15:44

1 Answers1

7

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.

JodaStephen
  • 60,927
  • 15
  • 95
  • 117