difference in seconds between two dates using joda time?

Use the Seconds class:

DateTime now = DateTime.now();
DateTime dateTime = now.plusMinutes(10);
Seconds seconds = Seconds.secondsBetween(now, dateTime);
System.out.println(seconds.getSeconds());

This piece of code prints out 600. I think this is what you need.

As further advice, explore the documentation of joda-time. It’s pretty good, and most things are very easy to discover.

In case you need some help with the parsing of dates (It’s in the docs, really), check out the related questions, like this:

Parsing date with Joda with time zone

Leave a Comment