Java Utililty Methods Year Ago

List of utility methods to do Year Ago

Description

The list of methods to do Year Ago are organized into topic(s).

Method

GregorianCalendargetHundredYearsAgo()
get Hundred Years Ago
final GregorianCalendar retVal = new GregorianCalendar();
retVal.add(Calendar.YEAR, -100);
return retVal;
booleanhasYearPassed(int year)
has Year Passed
return normalizeYear(year) < NOW.get(Calendar.YEAR);
DateyearAgo()
Get date for year ago
return forCalendarDiff(Calendar.YEAR, -1);
DateyearsAgo(int i)
years Ago
Calendar cal = getCalendarInstance();
cal.add(Calendar.YEAR, -i);
return cal.getTime();
DateyearsAgo(int n)
Get a Date for the specified number of years ago.
final Calendar cal = GregorianCalendar.getInstance();
cal.setTime(new Date(System.currentTimeMillis()));
cal.add(Calendar.YEAR, -n);
return cal.getTime();