Java Month Calculate getIntMonthShift(Date Shift)

Here you can find the source of getIntMonthShift(Date Shift)

Description

get Int Month Shift

License

Open Source License

Declaration

public static int getIntMonthShift(Date Shift) 

Method Source Code

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

import java.util.*;

public class Main {
    public static Date gamedate = new Date();

    public static int getIntMonthShift(Date Shift) {
        Calendar tempcalendar1 = GregorianCalendar.getInstance();
        Calendar tempcalendar2 = GregorianCalendar.getInstance();
        tempcalendar1.setTime(Shift);/*from   w w  w  .ja  va 2  s.co  m*/
        tempcalendar2.setTime(gamedate);
        int month1 = tempcalendar1.get(Calendar.MONTH);
        int month2 = tempcalendar2.get(Calendar.MONTH);
        month1 = month1 + 12 * (tempcalendar1.get(Calendar.YEAR) - tempcalendar2.get(Calendar.YEAR));
        return month1 - month2;
    }
}

Related

  1. getCurrentMonth()
  2. getCurrentMonthName()
  3. getDateMonthShift(int Shift)
  4. getDiffInMonths(Date firstDate, Date lastDate)
  5. getDisplayMonth(int month)
  6. getlastDateofThisMonth()
  7. getLastMonthBegin()
  8. getMonthFormat(String date)
  9. getMonthlyIntervals(Date start, Date end)