Android Month Date Get monthOffset(Date date, int offset)

Here you can find the source of monthOffset(Date date, int offset)

Description

month Offset

License

Open Source License

Declaration

public static Date monthOffset(Date date, int offset) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static Date monthOffset(Date date, int offset) {
        return offsetDate(date, Calendar.MONTH, offset);
    }//from   w w  w  . ja va2s. c o  m

    public static Date offsetDate(Date date, int field, int offset) {
        Calendar calendar = convert(date);
        calendar.add(field, offset);
        return calendar.getTime();
    }

    private static Calendar convert(Date date) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        return calendar;
    }
}

Related

  1. getMonthStartDate(Date date)
  2. getMonthEndDate(Date date)
  3. getCurrentMonth()
  4. monthNumber()
  5. getInterval(String beginMonth, String endMonth)
  6. getMonth()
  7. getCurrentMonth()
  8. getStringMonth(Date date)
  9. getMonth(int month, Locale locale)