Java Day End isIncludeDay(Date start, Date end, Date target)

Here you can find the source of isIncludeDay(Date start, Date end, Date target)

Description

is Include Day

License

Open Source License

Declaration

public static boolean isIncludeDay(Date start, Date end, Date target) 

Method Source Code


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

public class Main {

    public static boolean isIncludeDay(Date start, Date end, Date target) {
        start = initDate(start).getTime();
        Calendar endCal = initDate(end);
        endCal.add(Calendar.DAY_OF_MONTH, 1);
        end = endCal.getTime();/* ww  w  .j a v a 2 s .co  m*/
        return isIncludeDate(start, end, target);
    }

    private static Calendar initDate(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        initDate(cal);
        return cal;
    }

    private static void initDate(Calendar cal) {
        cal.set(Calendar.HOUR, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    }

    private static boolean isIncludeDate(Date start, Date end, Date target) {
        return ((start.compareTo(target) <= 0) && (target.compareTo(end) < 0));
    }
}

Related

  1. isEndOfMonth(Date d)
  2. isEndOfMonth(Date date)
  3. isEndOfMonth(Date nowday)
  4. isEndOfSeason(Date date)
  5. isEqualYMD(Date begindate, Date enddate)
  6. isInRange(Date myDate, Date dateStart, Date dateEnd)
  7. isInWorkDay(Calendar start)
  8. isMoreThenMonth(Date startDate, Date enDate)
  9. isNowBetween(Date start, Date end)