Here you can find the source of yesterday(int daybefore, String pattern)
public static String yesterday(int daybefore, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String yesterday(int daybefore, String pattern) { Calendar cal = yesterday(daybefore); return new SimpleDateFormat(pattern).format(cal.getTime()); }/*from w w w .j av a 2 s. c o m*/ public static Calendar yesterday(int daybefore) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -(daybefore + 1)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; } }