How to calculate Date Difference in Java?

Ads
Ads

How to calculate Date Difference in Java?


Java Coder
How to calculate Date Difference in Java?
1 Answer(s)      a year and a month ago
Posted in : Java Beginners
Ads

Hi,

I have two dates variable. How to calculate Date Difference in Java?

Thanks

View Answers

April 16, 2017 at 8:42 PM


Hi,

You can use the Calendar class for calculating the date difference in Java.

Get data into milliseconds like this:

long milliseconds1 = calendar1.getTimeInMillis();

And then easily find the date difference.

Check tutorial Date Difference.

Thanks


Ads