How to get difference between two dates?

Q & ACategory: JavaHow to get difference between two dates?
Admin Staff asked 5 years ago

How to get difference between two dates?
a) long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();
b) long diffInMilli = java.time.difference(dateTime1, dateTime2).toMillis();
c) Date diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();
d) Time diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();

1 Answers
Admin Staff answered 5 years ago

a) long diffInMilli = java.time.Duration.between(dateTime1, dateTime2).toMillis();