is Same Day between two Calendar - Android java.util

Android examples for java.util:Day

Description

is Same Day between two Calendar

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    /**//from ww  w.  j a va2  s . c  o m
     *
     * @param cal1
     * @param cal2
     * @return
     */
    public static boolean isSameDay(Calendar cal1, Calendar cal2) {
        if (cal1 == null || cal2 == null)
            throw new IllegalArgumentException("The dates must not be null");
        return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && (cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)) && (cal1
                    .get(Calendar.DAY_OF_YEAR) == cal2
                .get(Calendar.DAY_OF_YEAR)));
    }
}

Related Tutorials