skip to main | skip to sidebar

yawmark.com

Saturday, June 21, 2008

Update: "Days Difference" with Joda

The more I play with the Joda Time API, the more I like it. Revisiting the "calculating difference in days" problem, here's the Joda/Groovy equivalent:
import org.joda.time.LocalDate
import static org.joda.time.Days.*

date1 = new LocalDate(2008, 3, 10)
date2 = new LocalDate(2008, 3, 12)
assert 2 == daysBetween(date1, date2).days

What's not to like? :o)

 
Posted by Steve at 9:02 AM 0 comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: programming
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2012 (1)
    • ►  March (1)
  • ►  2011 (5)
    • ►  October (1)
    • ►  June (2)
    • ►  February (1)
    • ►  January (1)
  • ►  2010 (18)
    • ►  November (3)
    • ►  September (1)
    • ►  August (2)
    • ►  July (6)
    • ►  May (2)
    • ►  April (1)
    • ►  March (3)
  • ►  2009 (23)
    • ►  December (1)
    • ►  November (1)
    • ►  August (4)
    • ►  July (1)
    • ►  June (1)
    • ►  April (3)
    • ►  March (11)
    • ►  February (1)
  • ▼  2008 (2)
    • ▼  June (1)
      • Update: "Days Difference" with Joda
    • ►  May (1)
  • ►  2007 (11)
    • ►  December (2)
    • ►  October (1)
    • ►  September (3)
    • ►  August (1)
    • ►  July (2)
    • ►  June (2)

Search This Blog