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.
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.
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.