Java Day End getNextEndDate(Date date, int offset)

Here you can find the source of getNextEndDate(Date date, int offset)

Description

get Next End Date

License

Apache License

Declaration

public static Date getNextEndDate(Date date, int offset) 

Method Source Code

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

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

public class Main {
    public static Date getNextEndDate(Date date, int offset) {
        if (offset < 1) {
            return date;
        } else {/*w ww  .  java  2  s .  com*/
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);

            for (int dayOfWeek = calendar.get(7); offset > 0; --offset) {
                if (dayOfWeek == 6) {
                    calendar.add(5, 3);
                } else if (dayOfWeek == 7) {
                    calendar.add(5, 2);
                } else {
                    calendar.add(5, 1);
                }
            }

            return calendar.getTime();
        }
    }
}

Related

  1. getMonths(Date end, Date start)
  2. getMonthsBetweenBeginDateAndEndDate(Date beginDate, Date endDate)
  3. getMonthSpan(Date begin, Date end)
  4. getMonthSpan(Date start, Date end)
  5. getMsBetween(Date startDate, Date endDate)
  6. getNextSendTime(Date sendDate, Date start)
  7. getNumberOfDaysBetweenDates(Date beginDate, Date endDate)
  8. getNumberOfMonthsBetween(final Date begin, final Date end)
  9. getNumMonths(Date dStart, Date dEnd)