Let\'s say I have this:
PrintStream out = System.out; Scanner in = new Scanner(System.in); out.print(\"Enter a number ... \"); int n = in.nextInt();
You need to convert the Date to a Calendar.
Date
Calendar
Calendar c = Calendar.getInstance(); c.setTime(randomDate); c.add(Calendar.YEAR, n); newDate = c.getTime();
You can manipulate the Year (or other fields) as a Calendar, then convert it back to a Date.