How do you know how many days have passed since a special date? Which package do I need to use and how?
EDIT My previous answer was only valid for a year.
You can use the difference in milliseconds as follows:
Date date1 = // some date Date date2 = // some other date long difference = date2.getTime() - date1.getTime(); long differenceDays = difference / (1000 * 60 * 60 * 24);
Basically the same as timbooo, just a shorter way.
Only for the protocol - I love java.util.concurrent.TimeUnitthat.
java.util.concurrent.TimeUnit
Date d1 = ... Date d2 = ... long dif = d1.getTime() - d2.getTime(); long days = TimeUnit.MILLISECONDS.toDays(dif);
, , morja, TimeUnit . , 24, 60 .. , Java Code ( -1, 0 1 ) .
kodejava.org
Jodatime :
Date now = // some Date Date then = // some Date int days = Days.daysBetween(new DateTime(now), new DateTime(then)).getDays();
, , getTimeInMillis() ( 1970 ), , 1000/-a- /--/ . ;)