Here you can find the source of addDays(final Date date, final int addDays)
Parameter | Description |
---|---|
date | The Date object to add the days. |
addDays | The days to add. |
public static Date addDays(final Date date, final int addDays)
//package com.java2s; /**// w ww. ja v a 2s. c om * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; import java.util.Date; public class Main { /** * Adds days to the given Date object and returns it. Note: you can add negative values too for * get date in past. * * @param date * The Date object to add the days. * @param addDays * The days to add. * @return The resulted Date object. */ public static Date addDays(final Date date, final int addDays) { final Calendar dateOnCalendar = Calendar.getInstance(); dateOnCalendar.setTime(date); dateOnCalendar.add(Calendar.DATE, addDays); return dateOnCalendar.getTime(); } }