Java Day of Week getWeekFirstDay(Date weekday)

Here you can find the source of getWeekFirstDay(Date weekday)

Description

get Week First Day

License

Open Source License

Declaration

public static Date getWeekFirstDay(Date weekday) 

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 getWeekFirstDay(Date weekday) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(weekday);//from  ww  w.  j ava 2s .  com
        if (cal.get(cal.DAY_OF_WEEK) == 1) {//sunday
            cal.add(cal.DATE, -6);
        } else {
            cal.add(cal.DATE, 2 - cal.get(cal.DAY_OF_WEEK));
        }
        return cal.getTime();
    }
}

Related

  1. getWeekdayInterval(Date date)
  2. getWeekDayOfYear(Date date)
  3. getWeekDays(String _date, int _amount)
  4. getWeekDaysBetween(Date fromDate, Date toDate, int dayOfWeek)
  5. getWeekEnd(Date date, int w)
  6. getWeekID(Date dateValue)
  7. getWeekNum(Date date)
  8. getWeekNumber(Date date)
  9. getWeekNumber(Date date, Integer day)