Sunday, January 9, 2011

Joda Time == Good Times

I heard about Joda Time a couple months back, but finally got to use and implement it in a project.

We all know the whole Java date thing is ugly, and I sure most people have the own "implementations" and extensions like Period objects and utility Date Diff classes. I know I've written my fair share over the years. I won't be doing that again...

I am not going to go into too much detail as the Joda documentation is pretty good.
I just wanna highlight some of the very usual functionality that won me over:

Setting the "System" time, very useful. The financial systems I have worked on throughout my career always had some concept that required the "Current Date" mostly for data and rules with effective date periods.

Joda lets you statically set the "Current Date" making it a pleasure to test with, ensuring that any new DateTime objects used will be based off the set date:



Intervals:


The classic Date diff:


Working with "parts", just the date or the time:

Popular Posts

Followers