Here you can find the source of getDayBefore(Date date)
public static String getDayBefore(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static final String DEFAULT_PATTERN = "yyyy-MM-dd"; public static String getDayBefore(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from www . jav a 2 s .co m*/ cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1); return pattern(DEFAULT_PATTERN, cal.getTime()); } public static String pattern(String pattern, Date date) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } }