aspose file tools*
The moose likes Java in General and the fly likes API methods for difference between two dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "API methods for difference between two dates" Watch "API methods for difference between two dates" New topic
Author

API methods for difference between two dates

Peter Braun
Ranch Hand

Joined: Feb 09, 2005
Posts: 57
Somebody please tell me why don't create the Sun create methods for calculate difference between two dates? Days between two dates for example.

Thanks,
Peter
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

I don't know why Sun didn't add that to the standard library. But calculating the difference between to dates is easy. You just look at the millisecond values of your two Date objects and subtract them - then you have the difference in milliseconds. It's straightforward to convert this to days (just divide by 24 * 60 * 60 * 1000, which is the number of milliseconds in one day).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: API methods for difference between two dates
 
Similar Threads
how to get date month year time
difference between two dates
How to calculate difference between two dates in months
Problem in setting the date in a servlet
DateDiff Function in Java?