Java SQL Date Get getDateAddMonth(java.sql.Date date, int months)

Here you can find the source of getDateAddMonth(java.sql.Date date, int months)

Description

get Date Add Month

License

Apache License

Declaration

public static Date getDateAddMonth(java.sql.Date date, int months) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

import java.util.Date;

public class Main {
    public final static Calendar cal = Calendar.getInstance();

    public static Date getDateAddMonth(java.sql.Date date, int months) {
        if (date == null) {
            return null;
        }//  ww  w.  j  av  a  2 s.c o m

        cal.setTime(new java.util.Date(date.getTime()));

        int month = cal.get(java.util.Calendar.MONTH);
        cal.set(java.util.Calendar.MONTH, month + months);

        return new java.sql.Date(cal.getTime().getTime());
    }
}

Related

  1. getDate(String year, String month, String day)
  2. getDate(Timestamp establishdate)
  3. getDate(Timestamp timestamp)
  4. getDate(Timestamp timestamp)
  5. getDate(Timestamp ts)
  6. getDateAsLong(ResultSet rset, Enum field)
  7. getDateAsLong(Timestamp date)
  8. getDateBefore(Date date, Integer before)
  9. getDateBeforTwelveMonth()