Here you can find the source of getFewYearsTime(String date, int year)
public static String getFewYearsTime(String date, int year)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String getFewYearsTime(String date, int year) { int years = Integer.parseInt(date.split("-")[0]); int month = Integer.parseInt(date.split("-")[1]); int data = Integer.parseInt(date.split("-")[2]); Calendar calendar = new GregorianCalendar(years, month - 1, data); calendar.add(Calendar.YEAR, year); Date d = calendar.getTime(); return new SimpleDateFormat("yyyy-MM-dd").format(d); }/*from w w w .j av a 2 s . c om*/ }