Java Date Compare compareDay(Date date1, int compday)

Here you can find the source of compareDay(Date date1, int compday)

Description

compare Day

License

Apache License

Declaration

public static Boolean compareDay(Date date1, int compday) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Boolean compareDay(Date date1, int compday) {
        if (date1 == null)
            return false;
        Date dateComp = getDateBeforeOrAfter(date1, compday);
        Date nowdate = new Date();
        if (dateComp.after(nowdate))
            return true;
        else/* www  .ja  v a  2s . c  om*/
            return false;
    }

    public static Date getDateBeforeOrAfter(int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, iDate);
        return cal.getTime();
    }

    public static Date getDateBeforeOrAfter(Date curDate, int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(Calendar.DAY_OF_MONTH, iDate);
        return cal.getTime();
    }
}

Related

  1. compareDates(final String format, final Date date1, final Date date2)
  2. compareDateSequence(String startDate, String endDate)
  3. compareDatesOnly(long date1, long date2)
  4. compareDateTimeNull(Date d1, Date d2)
  5. compareDay(Date date, Date anotherDate)
  6. compareDays(final Date date1, final Date date2)
  7. compareFileDates(final Date date1, final Date date2)
  8. compareMonth(Date first, Date second)
  9. compareSecond(java.util.Date date1, java.util.Date date2)