Here you can find the source of addTime(Date aDate, int timeToAdd, int timeUnits)
Parameter | Description |
---|---|
aDate | A starting date to reference. |
timeToAdd | Amount of time to add to starting reference. |
timeUnits | Units of time for the timeToAdd field. |
public static Date addTime(Date aDate, int timeToAdd, int timeUnits)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**//from ww w. jav a2 s . c o m * Add time to a date with generic settings. * * @param aDate A starting date to reference. * @param timeToAdd Amount of time to add to starting reference. * @param timeUnits Units of time for the timeToAdd field. * @return The resultant date. */ public static Date addTime(Date aDate, int timeToAdd, int timeUnits) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(aDate); cal.add(timeUnits, timeToAdd); return cal.getTime(); } }