is Calendar Same Day - Java java.util

Java examples for java.util:Day

Description

is Calendar Same Day

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar a = Calendar.getInstance();
        Calendar b = Calendar.getInstance();
        System.out.println(isSameDay(a, b));
    }// ww  w. j  a  v  a2  s .c om

    public static boolean isSameDay(Calendar a, Calendar b) {
        return (a.get(Calendar.DATE) == b.get(Calendar.DATE)
                && a.get(Calendar.MONTH) == b.get(Calendar.MONTH) && a
                    .get(Calendar.YEAR) == b.get(Calendar.YEAR));
    }
}

Related Tutorials