is Current Day - Android java.util

Android examples for java.util:Day

Description

is Current Day

Demo Code


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

public class Main {
    public static boolean isCurrentDay(int[] date) {
        Calendar currentCal = Calendar.getInstance();
        if (date[0] == currentCal.get(Calendar.DAY_OF_MONTH)
                && date[1] == currentCal.get(Calendar.MONTH)
                && date[2] == currentCal.get(Calendar.YEAR))
            return true;
        else//from   w w w .j av  a2 s.c  o m
            return false;
    }

    public static boolean isCurrentDay(Calendar calendarDate) {
        Calendar currentDate = Calendar.getInstance();
        return isSameDay(currentDate, calendarDate);
    }

    public static boolean isSameDay(Calendar calendarDate1,
            Calendar calendarDate2) {
        if (calendarDate1.get(Calendar.YEAR) == calendarDate2
                .get(Calendar.YEAR)
                && calendarDate1.get(Calendar.MONTH) == calendarDate2
                        .get(Calendar.MONTH)
                && calendarDate1.get(Calendar.DAY_OF_MONTH) == calendarDate2
                        .get(Calendar.DAY_OF_MONTH))
            return true;
        else
            return false;
    }

    public static boolean isSameDay(int[] date1, int[] date2) {
        if (date1[0] == date2[0] && date1[1] == date2[1]
                && date1[2] == date2[2])
            return true;
        else
            return false;
    }
}

Related Tutorials