Java Day of Week firstDateAfterAddWeeks(Date early, int weeks)

Here you can find the source of firstDateAfterAddWeeks(Date early, int weeks)

Description

first Date After Add Weeks

License

Open Source License

Declaration

public static final Date firstDateAfterAddWeeks(Date early, int weeks) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.util.TimeZone;

public class Main {

    public static final Date firstDateAfterAddWeeks(Date early, int weeks) {
        Date firstDate = getThisweekFirst(early);
        firstDate = dayAdd(firstDate, weeks * 7);
        return firstDate;
    }/*from ww  w.  j a v a 2s  . c o  m*/

    public static final Date getThisweekFirst(Date early) {
        Calendar c1 = Calendar.getInstance();
        c1.setTime(early);
        int week = c1.get(Calendar.DAY_OF_WEEK);
        int firstw = -1 * (week - 1);
        Date weekFirst = dayAdd(early, firstw);
        return weekFirst;
    }

    public static Date dayAdd(Date date, int days) {

        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.setTime(date);
        cal.add(Calendar.DATE, days);

        return cal.getTime();
    }
}

Related

  1. dayOfWeekFromInteger(String aDay, boolean longName)
  2. dayOfWeekNames()
  3. endOfWeek(Date inDate, TimeZone timeZone)
  4. extractDayOfWeek(Date date)
  5. findDayOfWeek(String threeLetters)
  6. firstDayOfWeek()
  7. getAllDaysDateBetween(Date startDate, Date endDate, DayOfWeek dayOfWeek)
  8. getBounceDateofWeek(Date date)
  9. getDateByWeek(int week)