is Same Date In Calendar - Android java.util

Android examples for java.util:Calendar

Description

is Same Date In Calendar

Demo Code

/*/*from   www. j  a v  a 2 s  . c  o  m*/
 * Santiago Carrillo Barbosa - Android Calendar Picker
 * email: sancarbar@gmail.com
 *
 * https://github.com/sancarbar/Android-Calendar-Picker
 *
 * (C) 2013, Santiago Carrillo
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 3 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */
//package com.java2s;

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

public class Main {
    public static boolean isSameDateInCalendar(Calendar calendar, Date date) {
        Calendar dateCalendar = Calendar.getInstance();
        dateCalendar.setTime(date);
        return dateCalendar.get(Calendar.DAY_OF_MONTH) == calendar
                .get(Calendar.DAY_OF_MONTH)
                && dateCalendar.get(Calendar.MONTH) == calendar
                        .get(Calendar.MONTH)
                && dateCalendar.get(Calendar.YEAR) == calendar
                        .get(Calendar.YEAR);
    }
}

Related Tutorials