Java Year Get getFewYearsTime(String date, int year)

Here you can find the source of getFewYearsTime(String date, int year)

Description

get Few Years Time

License

Open Source License

Declaration

public static String getFewYearsTime(String date, int year) 

Method Source Code


//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*/
}

Related

  1. getCurrentYear()
  2. getCurrentYearAsInt()
  3. getCurrYearFirst()
  4. getDateOneYearFromNow()
  5. getDaysFromYearZero(Calendar date)
  6. getHalfYearEndDate(Date date)
  7. getLastDayOfYear(Date date)
  8. getNextYear()
  9. getNextYearFirst()