Here you can find the source of addDate(Date date, int calendarField, int numberToAdd)
Parameter | Description |
---|---|
date | The date to modify |
calendarField | The static field from java.util.Calendar to add |
numberToAdd | The number to add |
public static Date addDate(Date date, int calendarField, int numberToAdd)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { /**/* ww w . java 2 s. co m*/ * This method allows you to add to a java.util.Date returning a Date * instead of void like the Calendar does * * @param date * The date to modify * @param calendarField * The static field from java.util.Calendar to add * @param numberToAdd * The number to add * @return Date */ public static Date addDate(Date date, int calendarField, int numberToAdd) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(calendarField, numberToAdd); return c.getTime(); } }