Here you can find the source of adjustTimestamp(Timestamp stamp, Integer adjType, Integer adjQuantity)
public static Timestamp adjustTimestamp(Timestamp stamp, Integer adjType, Integer adjQuantity)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { /**//from www . jav a2 s . co m * Perform date/time arithmetic on a Timestamp. This is the only accurate * way to perform date/time arithmetic across locales and time zones. * * @param stamp * date/time to perform arithmetic on * @param adjType * the adjustment type to perform. Use one of the * java.util.Calendar fields. * @param adjQuantity * the adjustment quantity. * @param timeZone * @param locale * @return adjusted Timestamp * @see java.util.Calendar */ public static Timestamp adjustTimestamp(Timestamp stamp, int adjType, int adjQuantity, TimeZone timeZone, Locale locale) { Calendar tempCal = toCalendar(stamp, timeZone, locale); tempCal.add(adjType, adjQuantity); return new Timestamp(tempCal.getTimeInMillis()); } public static Timestamp adjustTimestamp(Timestamp stamp, Integer adjType, Integer adjQuantity) { Calendar tempCal = toCalendar(stamp); tempCal.add(adjType, adjQuantity); return new Timestamp(tempCal.getTimeInMillis()); } public static java.util.Calendar toCalendar(java.sql.Timestamp stamp) { Calendar cal = Calendar.getInstance(); if (stamp != null) { cal.setTimeInMillis(stamp.getTime()); } return cal; } /** * Returns a Calendar object initialized to the specified date/time, time * zone, and locale. * * @param date * date/time to use * @param timeZone * @param locale * @return Calendar object * @see java.util.Calendar */ public static Calendar toCalendar(Date date, TimeZone timeZone, Locale locale) { Calendar cal = Calendar.getInstance(timeZone, locale); if (date != null) { cal.setTime(date); } return cal; } }