Here you can find the source of getEndDateByYears(Date date, int years)
Parameter | Description |
---|---|
date | a parameter |
years | a parameter |
public static Date getEndDateByYears(Date date, int years)
//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(); } }