File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need clever date difference methods

 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got to do a fair number of date/calendar calculations using the number of months or weeks between dates. With either Date or Calendar objects, its trivial to get the number of days between to objects, but how do you get the number of months? How do you get the number of weeks? Clearly any discussion of months really requires a Calendar, and in this case, I can easily use a GregorianCalendar

Suppose you have two dates, say October 16, 2012 and January 3, 2012. How many months are they appart?
How do I calculate that they are 41 weeks apart? How can I figure out how many Tuesdays are between them?
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never had occasion to use Joda Time, but I believe it has an Interval class that may (or may not!) be useful here.

edit A quick glance at the JavaDocs suggests that Duration and/or Period may be the useful classes -- not Interval.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic