Java Date Equal yearMonthsEqual(final Date firstDate, final Date secondDate)

Here you can find the source of yearMonthsEqual(final Date firstDate, final Date secondDate)

Description

year Months Equal

License

Open Source License

Declaration

public static boolean yearMonthsEqual(final Date firstDate, final Date secondDate) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;

public class Main {
    public static boolean yearMonthsEqual(final Date firstDate, final Date secondDate) {

        final Calendar firstCal = Calendar.getInstance();
        firstCal.setTime(firstDate);/*from w w w. java 2 s  . c  o m*/

        final Calendar secondCal = Calendar.getInstance();
        secondCal.setTime(secondDate);

        return firstCal.get(Calendar.MONTH) == secondCal.get(Calendar.MONTH)
                && firstCal.get(Calendar.YEAR) == secondCal.get(Calendar.YEAR);
    }
}

Related

  1. isSameDate(long var0, long var2)
  2. monthEquals(Date current, Date compare)
  3. nowInDateEquals(Date now, Date d1, Date d2)
  4. sameDate(Date date1, Date date2)
  5. sameDate(Date date1, Date date2)