Java Day Between monthDiff(Date from, Date to)

Here you can find the source of monthDiff(Date from, Date to)

Description

month Diff

License

Open Source License

Declaration

public static int monthDiff(Date from, Date to) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static int monthDiff(Date from, Date to) {
        Calendar fromCal = Calendar.getInstance();

        Calendar toCal = Calendar.getInstance();

        fromCal.setTime(from);/*from  w w w . ja  v  a  2  s  .  com*/

        toCal.setTime(to);

        int monthDiff = (toCal.get(Calendar.YEAR) - fromCal.get(Calendar.YEAR)) * 12
                + (toCal.get(Calendar.MONTH) - fromCal.get(Calendar.MONTH));

        return monthDiff;

    }
}

Related

  1. getYearDiff(Date date1, Date date2)
  2. getYearsDifference(Date startTime, Date endTime)
  3. hourDiff(Date firstDate, Date lastDate)
  4. internalTrimOrAlterDate(Date date, boolean trim, int dayDiff)
  5. monthDiff(Date beginDate, Date endDate)
  6. monthDiff(Date fromDate, Date toDate)
  7. monthDifference(final Date a, final Date b)
  8. monthsDiff(final Date data1, final Date data2)
  9. stdNewDate(String tzDiff)