is Same Day Ignore Year - Android java.util

Android examples for java.util:Day

Description

is Same Day Ignore Year

Demo Code


//package com.java2s;

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

public class Main {
    public static boolean isSameDayIgnoreYear(Date date1, Date date2) {
        Calendar cal1 = buildFromDate(date1);
        Calendar cal2 = buildFromDate(date2);
        return cal1.get(Calendar.DAY_OF_YEAR) == cal2
                .get(Calendar.DAY_OF_YEAR);
    }// w  w w .  j a v a  2  s.c  o  m

    private static Calendar buildFromDate(Date from) {
        Calendar c = Calendar.getInstance();
        c.setTime(from);
        return c;
    }
}

Related Tutorials