Here you can find the source of yearAgo()
public static Date yearAgo()
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**//from www. j av a 2s . c o m * Get date for year ago * * @return date */ public static Date yearAgo() { return forCalendarDiff(Calendar.YEAR, -1); } /** * Get date for calendar difference from current date * * @param field difference field (Calendar.DATE, Calendar.MINUTE ... etc) * @param amount how much? * @return date for the difference */ public static Date forCalendarDiff(int field, int amount) { GregorianCalendar gCal = new GregorianCalendar(); gCal.add(field, amount); return new Date(gCal.getTimeInMillis()); } }