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 Android Security Essentials Live Lessons this week in the Android 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: 3029

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: 19656

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
Don't get me started about those stupid light bulbs.
subject: difference in days
Similar Threads
dates in java
Websphere Certification
HQL 2 – how to say “within X days from today”?
Date calculation
Date Generation