is Same Month between two date - Android java.util

Android examples for java.util:Month

Description

is Same Month between two date

Demo Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static boolean isSameMonth(Date date1, Date date2) {
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);/*from   www.j  a v  a 2s . c  o  m*/

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);

        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
    }
}

Related Tutorials