Java Day End getEndDateByYears(Date date, int years)

Here you can find the source of getEndDateByYears(Date date, int years)

Description

get End Date By Years

License

Open Source License

Parameter

Parameter Description
date a parameter
years a parameter

Declaration

public static Date getEndDateByYears(Date date, int years) 

Method Source Code

//package com.java2s;
/*/* w  w  w .j av  a  2 s  .c  o m*/
 * ==================================================================
 * The Huateng Software License
 *
 * Copyright (c) 2008-2012 TOPSCF  All rights reserved.
 * ==================================================================
 */

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getEndDateByYears(Date date, int years) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(calendar.YEAR, years);
        return calendar.getTime();
    }

    public static Date add(Date date, int field, int amount) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(field, amount);
        return c.getTime();
    }
}

Related

  1. getEndDate(Date date)
  2. getEndDate(Date startDate)
  3. getEndDate(int useMonth)
  4. getEndDate(String date)
  5. getEndDateByDate(Date date)
  6. getEndDateForYear()
  7. getEndDateOfCurrentSemester()
  8. getEndDateOfMonth(Date given)
  9. getEndMonth(Date sessionEnd, int year, int excessDays)