Here you can find the source of yesterday()
public static Date yesterday()
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { /**/*from ww w.j av a 2 s . c o m*/ * Milliseconds=14 * */ public static final int MILLISECOND = Calendar.MILLISECOND; /** * Seconds=13 * */ public static final int SECOND = Calendar.SECOND; /** * Minute=12 * */ public static final int MINUTE = Calendar.MINUTE; /** * Hour=11 * */ public static final int HOUR = Calendar.HOUR_OF_DAY; /** * Day=5 * */ public static final int DAY = Calendar.DAY_OF_MONTH; public static Date yesterday() { final Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(DAY, -1); // zero time (hour, minutes, seconds, milliseconds) calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } }