March 1, 2010

Joda Time - Difference between dates

In order to calculate a difference between dates, I've found many problems:
  • Leap years.
  • Minute, seconds differences between months and years.
  • Months with different amount of days, etc.
 And I was not going to develop all this, right?. Somebody must have already done this, so, I started searching. The result was Joda-time, a very handy library that is being used in projects like JBoss Seam.

With this library, my work only was to use it, so, if I wanted to calculate date differences, I just have to: