Java Day of Week getMondayFirstOfWeek(Date baseDate)

Here you can find the source of getMondayFirstOfWeek(Date baseDate)

Description

get Monday First Of Week

License

Open Source License

Declaration

public static Date getMondayFirstOfWeek(Date baseDate) 

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 getMondayFirstOfWeek(Date baseDate) {
        int dayofweek = getDayOfWeekForDate(baseDate);
        dayofweek = dayofweek == 1 ? dayofweek + 7 : dayofweek;
        return getDateAfterDays(baseDate, 2 - dayofweek);
    }/* ww w. j  a  va  2  s  .  co  m*/

    public static int getDayOfWeekForDate(Date day) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(day);
        return calendar.get(Calendar.DAY_OF_WEEK);
    }

    public static Date getDateAfterDays(Date date, int add_days) {
        Calendar time = Calendar.getInstance();
        time.setTime(date);
        time.add(Calendar.DATE, add_days);
        return time.getTime();
    }
}

Related

  1. getLastDayOfWeek(String str, int week)
  2. getLastDayWeek(String s)
  3. getLastMondayOfWeek(Date date)
  4. getLastWeekDate(Date date)
  5. getLastWeekDay(int weekDay, Date end)
  6. getMondayOfThisWeek(Date date)
  7. getMondayOfWeek(Date date)
  8. getNext(final java.util.Date date, final int dayofweek)
  9. getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min)