Here you can find the source of getDateBefore(final Date day)
public static Date getDateBefore(final Date day)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.concurrent.TimeUnit; public class Main { public static final long DATE = TimeUnit.DAYS.toMillis(1); public static Date getDateBefore(final Date day) { final Calendar c = Calendar.getInstance(); c.setTime(day);// w w w .jav a2s. com final int day1 = c.get(Calendar.DATE); c.set(Calendar.DATE, day1 - 1); return c.getTime(); } }