JAVA - Trting to work out the number of days between two dates

My dates are LocalDates with the format YYY-MM-DD

I am trying to do it like this
long daysBetweenD = bookingDepartureIn.toEpochDay();
long daysBetweenA = bookingArrivalIn.toEpochDay();
long daysetween = daysBetweenD - daysBetweenA;
int daysetween2 = toIntExact(daysetween);

However i keep getting a run time error on the first of those lines.

Any ideas?

It's abit hard to know exactly without any debugging info or any insight into the code other then those 5 lines.
But my best guess is you're trying to create a delta value from the two date values, and not the millisecond values of the two dates.
A date is not a long, or integer etc. which you can substract.
try using delta = dateObject2.getTime() - dateObject1.getTime(); i believe thats date method which returns the milliseconds since 1970 00:00:00 gmt.

Are you using the built in classes for date handling?
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
It's been a while since I've done any programming, but I think Java has everything you need built in to do this sort of thing.

also, obligitory googling

convert current time to seconds since unix epoch, do the same for the other date, subtract to get the difference, convert difference to the time format you need.

Worked thanks