• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Working with dates in java - JDK VS Joda ?

 
David Jason
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10268
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Winston Gutkowski
Bartender
Pie
Posts: 10268
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic