This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Working with dates in java - JDK VS Joda ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Working with dates in java - JDK VS Joda ?" Watch "Working with dates in java - JDK VS Joda ?" New topic
Author

Working with dates in java - JDK VS Joda ?

David Jason
Greenhorn

Joined: Aug 21, 2012
Posts: 27
I wanted to get the number of days between two dates (string or date objects).
I have looked at some posts here and there, and especially on stackoverflow.
It seems that people prefer Joda over JDK. How do I decide which one to use ?
Joda seems to be a small project, not backed by big corporations like Oracle.
What if the support for Joda is stopped soon ? Then what will I do if I find some
bug in the Joda API ? Are there any dangers in using Joda ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18709
    
    8

David Jason wrote:Joda seems to be a small project, not backed by big corporations like Oracle.


This is a major misunderstanding. Joda was considered for inclusion in Java 7, although in the end it was left out. It is extremely unusual for outside projects to be taken into the Java API, in fact I can't think of a single instance where that has ever happened. So "not backed by... Oracle" is about as far from the truth as it's possible to get.

What if the support for Joda is stopped soon ? Then what will I do if I find some
bug in the Joda API ? Are there any dangers in using Joda ?


It's an open-source project. And as I noted above, it's a very high-profile project and it isn't likely to go away anytime soon. But even if all of the people involved in maintaining and updating it were swept out to sea tomorrow and never seen again, that wouldn't matter. The source code is accessible to anybody in the world, and bugs can be repaired by anybody too. In fact they are more likely to be fixed quickly than bugs found in the standard API are -- and there are still bugs in the Calendar implementations even to this day. Being backed by a big corporation isn't all it's cracked up to be.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

David Jason wrote:Joda seems to be a small project, not backed by big corporations like Oracle.

Just to chime in with Paul. SSL/SSH would probably be categorized as a "small project" too (and it's open source), yet after 15 years it still provides the backbone for most secure transactions and communication on the Internet.
And what major corporation still refuses to include it as part of their wonderful Operating System? Hmmm....let me think....

And why not? Because they can't charge you for it.

As for Joda Time, it's a single-focus project that came about specifically because Java's native support for all things date- (and more specifically time-) related is so bad.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14278
    
  21

To me, the answer would be simple: always use Joda Time, because it has a much better design, is much more complete and consistent than the date and time APIs in Java's standard library.

Paul Clapham wrote:Joda was considered for inclusion in Java 7, although in the end it was left out.

The author of Joda Time (Stephen Colebourne) is still working on Project ThreeTen, which is a new date and time API to be included in Java's standard library, based on Joda Time. It didn't make it into Java 7, but maybe it will be included in Java 8 (or a later Java version).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

Jesper de Jong wrote:The author of Joda Time (Stephen Colebourne) is still working on Project ThreeTen, which is a new date and time API to be included in Java's standard library, based on Joda Time. It didn't make it into Java 7, but maybe it will be included in Java 8 (or a later Java version).

Thanks for that Jesper. I've been wondering what's going on with 310. I wonder if he'll be producing any 'beta' jars for us?

Winston
Avi Stramer
Greenhorn

Joined: Aug 23, 2012
Posts: 6

There are still people out there that use the JDK date API? Comparing the Java dates API vs Joda is like bringing a butter knife to a gun fight.

Joda has been around a long time, is mature, and is probably one of the most used 3rd party Java libraries in existence.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18709
    
    8

Well, you have to admit, when you're a beginner who can't even configure a classpath correctly, the idea of downloading a jar file from a website and making your application work correctly with it is a bit daunting.

And most of the people who post here struggling with how to find the number of days between two dates, using the JDK classes, are working in a conservative environment where if it isn't on the exam then it isn't worth knowing, and any advances made since 2002 are dangerously radical innovations. (Okay, I exaggerate somewhat, but that theory explains a lot of the posts you see here.)
 
jQuery in Action, 2nd edition
 
subject: Working with dates in java - JDK VS Joda ?