Java Day of Week getLastDayOfWeek(Date date)

Here you can find the source of getLastDayOfWeek(Date date)

Description

get Last Day Of Week

License

Open Source License

Declaration

public static Date getLastDayOfWeek(Date date) 

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 getLastDayOfWeek(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from  w  ww .  ja  v a 2  s  .  com*/

        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            calendar.add(Calendar.DAY_OF_YEAR, -1);
        }

        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        calendar.add(Calendar.DATE, 6);

        return calendar.getTime();
    }
}

Related

  1. getIsoWeek(java.util.Date date)
  2. getLastDayFromLastWeek(Date d)
  3. getLastDayOfTheWeek(Date date)
  4. getLastDayOfWeek(Date date)
  5. getLastDayOfWeek(Date date)
  6. getLastDayOfWeek(Date date)
  7. getLastDayOfWeek(Date date)
  8. getLastDayOfWeek(String str, int week)
  9. getLastDayWeek(String s)