Possible Duplicate:
How do you subtract Dates in Java?
I am creating java desktop application. In that application user give some date inputs. so i use 3party library “jCalendar.jar”. for validation i want to subtract two dates. is there any way to subtract two dates in java?
If you are using a Java Date or Java Calendar, then you could use something like:
edit:
As pointed in the comments, storing the result in a calendar wouldn’t make much sense. You can still use the milliseconds returned for your operations.
If possible you could also use a library to handle this, like JODA.
It allows you to get the number of seconds/minutes/days/months/etc from between two dates and more things.