I insert some data into Sqlite database and check before insert if record for this day allready exists. To check this I have to see if number of days are >0. For example difference (in days) between 2011-8-6 and 2011-8-5 is 1. How to do this in Java?
EDIT: As @RayToal mentioned this could be done in database, so I did on that way:
SELECT julianday('now') - julianday(Date(Date)) from VIDEO_HISTORY;
Only problem with this is that it gives me decimal number. For example: 3.3442346529103816 Now I have to decide inside Java if given number is 3 of 4 days. It code is for app that searches youtube for some term and writes statistical data about daily views into database. User is able to schedule job for example every day in 20:00 o'clock. But then he could decide to reschedule this job in 10:00 o'clock, so program has to understood this like difference is one day. So it's obvious that I have to round to first bigger number. Is there some method for this or I have to write myself?
EDIT2: According to links provided by @Michael-O this is best solution (using JodaTime):
DateTime start = new DateTime(new GregorianCalendar(2011, 8, 4).getTime());
DateTime end = new DateTime(new GregorianCalendar(2011, 8, 8).getTime());
int numberOfDays = Days.daysBetween(start.toDateMidnight(), end.toDateMidnight()).getDays();
System.out.println(numberOfDays);