Java Day End getSendTime(Date sendDate, Date start, Date end)

Here you can find the source of getSendTime(Date sendDate, Date start, Date end)

Description

get Send Time

License

Open Source License

Declaration

public static Date getSendTime(Date sendDate, Date start, Date end) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Date getSendTime(Date sendDate, Date start, Date end) {
        Calendar calendar = Calendar.getInstance();
        if (sendDate != null) {
            calendar.setTime(sendDate);//  w ww  . jav  a2 s  .c  om
        }
        Calendar startCalendar = Calendar.getInstance();
        startCalendar.setTime(start);
        Calendar endCalendar = Calendar.getInstance();
        endCalendar.setTime(end);
        startCalendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        endCalendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        startCalendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        endCalendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        startCalendar.set(Calendar.DATE, calendar.get(Calendar.DATE));
        endCalendar.set(Calendar.DATE, calendar.get(Calendar.DATE));
        if (calendar.after(startCalendar) && calendar.before(endCalendar)) {
            return sendDate;
        } else if (calendar.before(startCalendar)) {
            return startCalendar.getTime();
        } else {
            startCalendar.add(Calendar.DATE, 1);
            return startCalendar.getTime();
        }

    }
}

Related

  1. getNumberOfMonthsBetween(final Date begin, final Date end)
  2. getNumMonths(Date dStart, Date dEnd)
  3. getNumYears(Date dStart, Date dEnd)
  4. getSCDEndDate()
  5. getSecondSemesterEndDate(Integer year)
  6. getStartAndEndDate(Date d)
  7. getStartOrEndTime(Date date, int flag)
  8. getSubSeconds(Date minuendDate, Date subDate)
  9. getTimeBeetweenDates(Date d1, Date d2, int timeType)