How to get Exact day difference between two dates in java or groovy? <p>I am calculating the difference between two sql dates, <code>TripStartDate</code> and <code>TripEndDate</code>.<br> If <code>TripStartDate= 2011-03-04 09:35:00</code> and <code>TripEndDate = 2011-03-04 10:35:00</code> then I should get the number of day is 1 (because trip happened on that day). </p> <p>Like this:</p> <p>If <code>TripStartDate = 2011-03-04 09:35:00</code> and <code>TripEndDate = 2011-03-05 09:35:00</code> then method should return 2 days (because trip happened on both days).</p> <p>If <code>TripStartDate = 2011-03-04 09:35:00</code> and <code>TripEndDate = 2011-04-04 09:35:00</code> then method should return 32 days. (because 28 days in march and 4 days in April).</p> <p>Calculation should be based on only dates and month of year (not taking time in consideration). Please help me . Thanks in advance... </p>