Here you can find the source of getWithDaysAdded( GregorianCalendar originalDate, int days)
Parameter | Description |
---|---|
originalDate | the original date to start from |
days | the number of days to add |
public static GregorianCalendar getWithDaysAdded( GregorianCalendar originalDate, int days)
//package com.java2s; /**/* w w w .j a va 2 s . c o m*/ * Copyright (c) 2010 Martin Geisse * * This file is distributed under the terms of the MIT license. */ import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /** * Returns a new {@link GregorianCalendar} instance that is the specified value plus the * specified number of days added. The original date is left unchanged. The result has * the same time-of-day as the original. * @param originalDate the original date to start from * @param days the number of days to add * @return the new date */ public static GregorianCalendar getWithDaysAdded( GregorianCalendar originalDate, int days) { GregorianCalendar newDate = (GregorianCalendar) originalDate .clone(); newDate.add(Calendar.DAY_OF_MONTH, days); return newDate; } }