This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Dates" Watch "Dates" New topic


Giomar Guevara
Ranch Hand

Joined: Oct 18, 2006
Posts: 51
I want to get the difference between 2 dates and get it in hours....

How can I do that?
David Buzatto

Joined: Jul 16, 2006
Posts: 9
Take a look in the Joda Time API.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (Fowler)
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Take a look at these JavaWorld articles: Calculating Java dates and Working in Java time : Learn the basics of calculating elapsed time in Java - they do a nice job of explaining Date math in Java.
I agree. Here's the link:
subject: Dates