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;

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

public class Main {

    public static Date getLastDayOfWeek(Date date) {
        Calendar c = new GregorianCalendar();
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.setTime(date);/*from   w  w w .j a va 2s  . com*/
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); // Sunday
        return c.getTime();
    }

    @SuppressWarnings("deprecation")
    public static Date getFirstDayOfWeek(Date date) {
        Calendar c = new GregorianCalendar();
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
        return c.getTime();
    }
}

Related

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