File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes difference in days 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 » Java in General
Bookmark "difference in days" Watch "difference in days" New topic

difference in days

asif Shaikh

Joined: Jan 29, 2010
Posts: 2
How do I calculate the number of days left of a future date from the current date?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3360

Using java.util.Date,
futureDay.getTime() - today.getTime() returns the number of milliseconds between today and the 'future'.
Do some maths to get the number of days from it.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Rob Spoor

Joined: Oct 27, 2005
Posts: 19911

Except that doesn't work with Daylight Savings Time.

Search this forum, this question has been asked and answered (among others by me) several times before.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: difference in days