Convert the Date
object to a Calendar
object and return it in one day. Something like this helper method takes from here :
public static void addDays(Date d, int days) { Calendar c = Calendar.getInstance(); c.setTime(d); c.add(Calendar.DATE, days); d.setTime(c.getTime().getTime()); }
For your specific case, just go to days
as -1
, and you need to do this. Just make sure you consider the time zone / locale if you are doing specific date manipulations.
source share