File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes difference between two dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between two dates" Watch "difference between two dates" New topic

difference between two dates

shalini gnana
Ranch Hand

Joined: Sep 18, 2007
Posts: 189
I have dates in an arraylist...How can i find the difference between two dates?
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
I can't catch your question exactly.
To check if two dates are identical, you can use compareTo(Date other) method and see if it returns 0.
You can get difference (miliseconds) between date1 and date2 from date1.getTime()-date2.getTime().
[ February 14, 2008: Message edited by: Daesung Park ]

Daesung Park

Rob Spoor

Joined: Oct 27, 2005
Posts: 19896

If you need the difference in days, please use the Search optionality. I've given answers to that same question in at least 3 different threads.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: difference between two dates