Here you can find the source of addDaysToTimestamp(Timestamp timestamp, int numDays)
Parameter | Description |
---|---|
date | Timestamp to be add |
numDays | Number of days to add |
public static Timestamp addDaysToTimestamp(Timestamp timestamp, int numDays)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.util.Calendar; public class Main { /**/* w ww. j av a 2 s .co m*/ * Adds the specified number of Days to the specified Date object * To subtract the specified number of Days to the specified Date object, juz use a negative number * Example: DateUtil.addDaysToDate(date, -5) == subtracting 5 days from the specified date. * * @param date Timestamp to be add * @param numDays Number of days to add * * @return date Added Date */ public static Timestamp addDaysToTimestamp(Timestamp timestamp, int numDays) { if (timestamp == null) { return null; } Calendar c = Calendar.getInstance(); c.setTime(timestamp); c.add(Calendar.DATE, numDays); return new Timestamp(c.getTimeInMillis()); } }