Here you can find the source of add2Calendar(Calendar cal, int years, int months, int days, int hours, int minutes, int seconds, int millis)
Parameter | Description |
---|---|
cal | a Calendar instance to modify. |
years | the number of years to add. |
months | the number of months to add. |
days | the number of days to add. |
hours | the number of hours to add. |
minutes | the number of minutes to add. |
seconds | the number of seconds to add. |
millis | the number of milliseconds to add. |
public static Calendar add2Calendar(Calendar cal, int years, int months, int days, int hours, int minutes, int seconds, int millis)
//package com.java2s; /*/*from w w w .j av a 2s. c o m*/ * Copyright (c) 2015-2016 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ import java.util.Calendar; public class Main { /** * Adds the specified values to the values to the specified Calendar instance and returns * the result. * * @param cal a Calendar instance to modify. * @param years the number of years to add. * @param months the number of months to add. * @param days the number of days to add. * @param hours the number of hours to add. * @param minutes the number of minutes to add. * @param seconds the number of seconds to add. * @param millis the number of milliseconds to add. * @return the updated Calendar instance. */ // CSOFF: ParameterNumber public static Calendar add2Calendar(Calendar cal, int years, int months, int days, int hours, int minutes, int seconds, int millis) // CSON: ParameterNumber { if (years != 0) cal.add(Calendar.YEAR, years); if (months != 0) cal.add(Calendar.MONTH, months); if (days != 0) cal.add(Calendar.DAY_OF_MONTH, days); if (hours != 0) cal.add(Calendar.HOUR_OF_DAY, hours); if (minutes != 0) cal.add(Calendar.MINUTE, minutes); if (seconds != 0) cal.add(Calendar.SECOND, seconds); if (millis != 0) cal.add(Calendar.MILLISECOND, millis); return cal; } }