is Calendar After A Day - Android java.util

Android examples for java.util:Day

Description

is Calendar After A Day

Demo Code


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

import android.util.Log;

public class Main {

    public static boolean isAfterADay(Calendar newCalendar,
            Calendar oldCalendar) {
        Log.d("TEST", "run isAferDay");
        if (newCalendar.get(Calendar.YEAR) > oldCalendar.get(Calendar.YEAR))
            return true;
        if (newCalendar.get(Calendar.YEAR) == oldCalendar
                .get(Calendar.YEAR)
                && newCalendar.get(Calendar.MONTH) > oldCalendar
                        .get(Calendar.MONTH))
            return true;
        if (newCalendar.get(Calendar.YEAR) == oldCalendar
                .get(Calendar.YEAR)
                && newCalendar.get(Calendar.MONTH) == oldCalendar
                        .get(Calendar.MONTH)
                && newCalendar.get(Calendar.DAY_OF_MONTH) > oldCalendar
                        .get(Calendar.DAY_OF_MONTH))
            return true;
        return false;
    }//w  w  w.j  a v  a  2s. co  m
}

Related Tutorials