Java Date API’s vs. Joda Time – What month is it?

As a java developer, I have a special place in my heart for the Java Date object and it’s related utility classes. In a series of posts I am going to exhort the benefits of using the Joda Time library and abandoning the Java date and time objects. From their site, the Joda Project is “…a Java open-source project that seeks to improve core Java functionality.” While they have a couple of other projects, the most active appears to be the Joda-Time project where the current version 1.6.1 was released on 2010-08-08.

We will start with a VERY basic example by comparing the simple task of pulling the current month full name and partial name. In Java there are several ways to do this, but I will choose to show a couple of the more common ways.

 

Java Calendar Object: Get the name of the current month:

 

As you can see, using the Java Calendar Object takes a bit of work to get the desired result. Oh, and if you also want short month names, you have to create that too.

Java SimpleDateFormat Object: Get the name of the current month:

 

Wow, so we have now effectively made the job a lot easier with the SimpleDateFormatter object. Or have we? You still end up having to create and work with objects which aren’t actual date objects. Klunky to me.

Joda-Time DateTime Object: Get the name of the current month:

 

Ahhhh, this is better. With the Joda-Time library it is as simple as calling a couple of methods to get the current month full name or short name. It really is intuitive and easy.

The Result:
Ok, so not a lot of complex code here, but this is just a sample of more to come. As someone who has struggled to find a happy life with the Java Date implementation I have found Joda-Time to be a breath of fresh air. Check out the Joda site and take the Joda-Time library out for a spin. I think you will like the results.

~Demian

Continue reading “Java Date API’s vs. Joda Time – What month is it?”

At the starting gate…

Come one! Come all! To the greatest spectacle known to man.  Come see the blogging, photography, software writing, freak guy…  Or something like that.  Hey, what am I supposed to put in a first post of a blog?  This is officially my first post of my blog found at www.demian.is.  You should visit that link sometime…..

Ok, well as you may notice I can’t really call this my first post since you obviously see there are others below.  It IS however my first post at my new home here at www.demian.is, and all of the other posts prior to this are from a previous blog that I used to grind on.  I am finally committing to creating what I wanted to create years ago which is a blog that I can update with my photography, my code, and a couple of articles a week that aim to help the technology world out.

THE PLAN
The plan here is to post for myself and for anyone else that my painfully learned life lessons can help.  Once I get everything setup on this site I will be writing two articles a week that are aimed at either helping someone through a problem, reviewing something like iphones or cameras or code, or highlighting something that would be useful to someone.

So, sit back and relax…
As I am just starting back up it may take me a few weeks to get into a proper rhythm, but give me time.  This should be one heck of a ride.  Stay tuned as there is MUCH more to come.

Demian Seiler