Java Day of Week getWeekEnd(Date date, int w)

Here you can find the source of getWeekEnd(Date date, int w)

Description

get Week End

License

Open Source License

Declaration

public static Date getWeekEnd(Date date, int w) 

Method Source Code

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

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

public class Main {
    public static Date getWeekEnd(Date date, int w) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*  w  ww . j a  va2 s  .co  m*/
        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
        if (dayOfWeek == 0) {
            dayOfWeek = 7;
        }
        c.add(Calendar.DATE, -dayOfWeek + 7);
        c.add(Calendar.WEEK_OF_MONTH, w);
        return c.getTime();
    }
}

Related

  1. getWeekdayDate(Date actualDate)
  2. getWeekdayInterval(Date date)
  3. getWeekDayOfYear(Date date)
  4. getWeekDays(String _date, int _amount)
  5. getWeekDaysBetween(Date fromDate, Date toDate, int dayOfWeek)
  6. getWeekFirstDay(Date weekday)
  7. getWeekID(Date dateValue)
  8. getWeekNum(Date date)
  9. getWeekNumber(Date date)