Java Day End countMonths(java.util.Date startDate, java.util.Date endDate)

Here you can find the source of countMonths(java.util.Date startDate, java.util.Date endDate)

Description

count Months

License

Open Source License

Declaration

public static int countMonths(java.util.Date startDate, java.util.Date endDate)
            throws IllegalArgumentException 

Method Source Code

//package com.java2s;
/**//from   w w  w  . ja  v a  2 s  .com
 * Copyrights 2002-2011 Webb Fontaine
 * This software is the proprietary information of Webb Fontaine.
 * Its use is subject to License terms.
 * Developer: nigiyan
 * Date: 04/11/2011
 */

import java.util.Calendar;

public class Main {
    private static Calendar cal1 = Calendar.getInstance();
    private static Calendar cal2 = Calendar.getInstance();

    public static int countMonths(java.util.Date startDate, java.util.Date endDate)
            throws IllegalArgumentException {
        cal1.setTime(endDate);
        cal2.setTime(startDate);

        return ((cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR)) * 12) + cal1.get(Calendar.MONTH)
                - cal2.get(Calendar.MONTH);

    }
}

Related

  1. calcYears(Date startDate, Date endDate)
  2. calenderFromDateString(String dateAndTime)
  3. checkTimeInRangeWithSkew(Date timeToCheck, Date startDate, Date endDate, int skewInMinutes)
  4. checkTimePeriod(final Date beginHour, final Date endHour, final Date hour)
  5. countDaysBetween(Date start, Date end)
  6. dateBetweens(Date start, Date end)
  7. dateSpan(Date beginDate, Date endDate)
  8. dayBetweenTwoDates(Date beginDate, Date endDate)
  9. dayEnd(Date dt)