Here you can find the source of getStartOfDayRelative(int daysFromToday)
public static Calendar getStartOfDayRelative(int daysFromToday)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**//from w ww . ja v a 2 s . c o m * 1 hour, represented as millis */ public static final long HOUR = (1000 * 60) * 60; /** * 1 minute, represented as millis */ public static final long MINUTE = 1000 * 60; /** * 1 second, represented as millis */ public static final long SECOND = 1000; public static Calendar getStartOfDayRelative(int daysFromToday) { Calendar rtn = getBeginningOfDay(); rtn.add(Calendar.DATE, daysFromToday); return rtn; } /** * Returns a date of the beginning of today. * * @return beginning of today */ public static Calendar getBeginningOfDay() { Calendar today = new GregorianCalendar(); today.set(Calendar.HOUR, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); return today; } }