Here you can find the source of yesterday()
public static Date yesterday()
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static Date yesterday() { return toYesterday(today()); }// w w w. j a va2 s .c om public static Date toYesterday(Date date) { return add(date, Calendar.DAY_OF_YEAR, -1); } /** * @return */ public static Date today() { return toDay(new Date()); } public static Date toDay(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } private static Date add(Date date, int field, int value) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date.getTime()); cal.add(field, value); return cal.getTime(); } }