Here you can find the source of getDateBefore(int year, int month, int day)
public static Date getDateBefore(int year, int month, int day)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateBefore(int year, int month, int day) { Date result = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(result);/*w w w .j a v a 2 s . com*/ calendar.add(Calendar.YEAR, year); calendar.add(Calendar.MONTH, month); calendar.add(Calendar.DAY_OF_MONTH, day); result = calendar.getTime(); return result; } public static Date getDateBefore(Date date, int year, int month, int day) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.YEAR, year); calendar.add(Calendar.MONTH, month); calendar.add(Calendar.DAY_OF_MONTH, day); date = calendar.getTime(); return date; } }