Here you can find the source of addMonth(java.sql.Timestamp src, int val)
Parameter | Description |
---|---|
src | Source timestamp. |
val | Number of months going to add, can be negative number. |
public static java.sql.Timestamp addMonth(java.sql.Timestamp src, int val)
//package com.java2s; /*/*from w ww . j a va 2 s. co m*/ * @(#)Utility.java * * Copyright (c) 2003 DCIVision Ltd * All rights reserved. * * This software is the confidential and proprietary information of DCIVision * Ltd ("Confidential Information"). You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of the license * agreement you entered into with DCIVision Ltd. */ public class Main { /** * addMonth - Returns the timestamp after adding certain amount of Month. * * @param src Source timestamp. * @param val Number of months going to add, can be negative number. * @return Timestamp after adding certain amount of months. */ public static java.sql.Timestamp addMonth(java.sql.Timestamp src, int val) { java.util.Calendar tmpCal = timestampToCalendar(src); if (tmpCal == null) { return (null); } tmpCal.add(java.util.Calendar.MONTH, val); return (calendarToTimestamp(tmpCal)); } /** * Returns Calendar converted from Timestamp. * * @param inTime Source timestamp which to be converted. * @return Calendar object which converted from input. */ public static java.util.Calendar timestampToCalendar(java.sql.Timestamp inTime) { if (inTime == null) { return (null); } java.util.Calendar cal = java.util.Calendar.getInstance(); cal.setTime(inTime); return (cal); } /** * Returns Timestamp converted from Calendar. * * @param inCal Source calendar which to be converted. * @return Timestamp object which converted from input. */ public static java.sql.Timestamp calendarToTimestamp(java.util.Calendar inCal) { if (inCal == null) { return (null); } java.sql.Timestamp time = new java.sql.Timestamp(inCal.getTime().getTime()); return (time); } }