is Same Date between two date value - Android java.util

Android examples for java.util:Date Algorithm

Description

is Same Date between two date value

Demo Code

import android.annotation.SuppressLint;
import android.text.format.DateUtils;
import android.text.format.Time;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main{

    /**//from  ww w .ja v  a 2 s . co  m
     * check Date is same day
     * @param baseDate
     * @param thenDate
     * @return
     */
    public static boolean isSameDate(Date baseDate, Date thenDate) {
        Time time = new Time();
        time.set(thenDate.getTime());

        int thenYear = time.year;
        int thenMonth = time.month;
        int thenMonthDay = time.monthDay;

        time.set(baseDate.getTime());
        return (thenYear == time.year) && (thenMonth == time.month)
                && (thenMonthDay == time.monthDay);
    }

}

Related Tutorials