Java Day of Week getLastMondayOfWeek(Date date)

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

Description

get Last Monday Of Week

License

Apache License

Declaration

public static Date getLastMondayOfWeek(Date date) 

Method Source Code

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

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

public class Main {
    public static int FIRST_DAY_OF_WEEK = Calendar.MONDAY;

    public static Date getLastMondayOfWeek(Date date) {
        Date thismonday = getMondayOfWeek(date);
        Calendar monday = getCalendar();
        monday.setTime(thismonday);/*from   ww  w.  ja va  2  s  .  c  o  m*/
        monday.add(Calendar.DAY_OF_YEAR, -7);
        return monday.getTime();
    }

    public static Date getMondayOfWeek(Date date) {
        Calendar monday = getCalendar();
        monday.setTime(date);
        monday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        monday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return monday.getTime();
    }

    public static Date getMondayOfWeek(int year, int weekOfYear) {
        Calendar monday = getCalendar();
        monday.set(Calendar.YEAR, year);
        monday.set(Calendar.WEEK_OF_YEAR, weekOfYear + 1);
        monday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        monday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return monday.getTime();
    }

    private static Calendar getCalendar() {
        Calendar c = Calendar.getInstance();
        c.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        return c;
    }
}

Related

  1. getLastDayOfWeek(Date date)
  2. getLastDayOfWeek(Date date)
  3. getLastDayOfWeek(Date date)
  4. getLastDayOfWeek(String str, int week)
  5. getLastDayWeek(String s)
  6. getLastWeekDate(Date date)
  7. getLastWeekDay(int weekDay, Date end)
  8. getMondayFirstOfWeek(Date baseDate)
  9. getMondayOfThisWeek(Date date)