Java Day of Week getThisweekFirst(Date early)

Here you can find the source of getThisweekFirst(Date early)

Description

get Thisweek First

License

Open Source License

Declaration

public static final Date getThisweekFirst(Date early) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.util.TimeZone;

public class Main {

    public static final Date getThisweekFirst(Date early) {
        Calendar c1 = Calendar.getInstance();
        c1.setTime(early);/*from   w  ww  .java2s .  c o  m*/
        int week = c1.get(Calendar.DAY_OF_WEEK);
        int firstw = -1 * (week - 1);
        Date weekFirst = dayAdd(early, firstw);
        return weekFirst;
    }

    public static Date dayAdd(Date date, int days) {

        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.setTime(date);
        cal.add(Calendar.DATE, days);

        return cal.getTime();
    }
}

Related

  1. getSeqWeekByMonth(Date currDate)
  2. getStartDate(int year, int week)
  3. getStartDates(Date baseDate, int weekNum)
  4. getSundayDate(int week, int year)
  5. getSundayOfWeek(Date date)
  6. getWeek(Date date)
  7. getWeek(Date date)
  8. getWeek(Date dateParam)
  9. getWeek(Date today)