I am trying to find difference in days between two dates. I am using this approach
Calendar currentTimeCalendar = Calendar.getInstance();
Calendar postModificationTimeCalendar = Calendar.getInstance();
postModificationTimeCalendar.setTime(dateeventoccured); //dateeventoccured is in format = Tue Jan 03 00:44:46 EST 2017
long diffInMillis = currentTimeCalendar.getTimeInMillis() - postModificationTimeCalendar.getTimeInMillis();
long days = diffInMillis/ (24*60*60*1000);
Now the problem is suppose, I posted something yesterday at 5 pm ,When it is 12 in midnight today difference should be 1 and date should be like yesterday.
but the days remains 0 ,until next day 5 is reached.How to achieve that. I want to show dates as today,yesterday and previous dates.