Java Month Add monthAdd(final String strDate, final int month)

Here you can find the source of monthAdd(final String strDate, final int month)

Description

month Add

License

Apache License

Declaration

public static String monthAdd(final String strDate, final int month) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String monthAdd(final String strDate, final int month) {
        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date;// w  ww. j a v a2  s .  c  om
        try {
            date = simpleDateFormat.parse(strDate);
            final Calendar calender = Calendar.getInstance();
            calender.setTime(date);
            calender.add(Calendar.MONTH, month);
            return simpleDateFormat.format(calender.getTime());
        } catch (final ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. addMonthsAndDays(Date date, int months, int days)
  2. addMonthTimetamp(long lTimeStamp, String _pattern, int month)
  3. getEndOfMonth(Date currentDate)
  4. getEndOfMonth(Date date)
  5. getEndOfMonth(long date)