aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 2891

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
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Rob Spoor

Joined: Oct 27, 2005
Posts: 19556

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
Similar Threads
dates in java
Websphere Certification
Date calculation
HQL 2 – how to say “within X days from today”?
Date Generation