aspose file tools*
The moose likes Beginning Java and the fly likes DateDiff Function in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "DateDiff Function in Java?" Watch "DateDiff Function in Java?" New topic
Author

DateDiff Function in Java?

Sonny Wong
Greenhorn

Joined: Dec 02, 2001
Posts: 2
Does anyone know that the Java API has a simple method to find out the time difference between two Gregorian Date objects in date?
John Fairbairn
Ranch Hand

Joined: May 30, 2002
Posts: 55
To compute the difference between two dates, I usually convert the dates to java.util.Date objects, call their getTime() methods, and subtract.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Originally posted by J Fairbairn:
To compute the difference between two dates, I usually convert the dates to java.util.Date objects, call their getTime() methods, and subtract.

You could just use the Calendar's getTimeInMillis() method. That method returns a long.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Sonny Wong
Greenhorn

Joined: Dec 02, 2001
Posts: 2
I tried the getTimeInMillis method and is working. Thanks guys!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DateDiff Function in Java?