Here you can find the source of beforeNDays(Calendar c, int n)
public static Calendar beforeNDays(Calendar c, int n)
//package com.java2s; import java.util.Calendar; public class Main { public static Calendar beforeNDays(Calendar c, int n) { long offset = n * 24 * 60 * 60 * 1000; Calendar calendar = null; if (c != null) { calendar = c;//from w ww . j av a 2 s . c om } else { calendar = Calendar.getInstance(); } calendar.setTimeInMillis(calendar.getTimeInMillis() - offset); return calendar; } }