Java Day of Week getDateOfWeek(int year, int weekOfYear, int i)

Here you can find the source of getDateOfWeek(int year, int weekOfYear, int i)

Description

get Date Of Week

License

Apache License

Declaration

public static Date getDateOfWeek(int year, int weekOfYear, int i) 

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 getDateOfWeek(int year, int weekOfYear, int i) {
        Calendar day = getCalendar();
        day.set(Calendar.YEAR, year);
        day.set(Calendar.WEEK_OF_YEAR, weekOfYear + 1);
        day.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        switch (i) {
        case 0:/*www  . j a  v  a2  s  .  c om*/
            day.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            break;
        case 1:
            day.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
            break;
        case 2:
            day.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
            break;
        case 3:
            day.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
            break;
        case 4:
            day.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
            break;
        case 5:
            day.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
            break;
        case 6:
            day.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
            break;
        }

        return day.getTime();
    }

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

Related

  1. getBounceDateofWeek(Date date)
  2. getDateByWeek(int week)
  3. getDateByYearAndWeekNum(int year, int weekNum)
  4. getDateForCurrentWeekDay(int day)
  5. getDateOfWeek(int week)
  6. getDateOfYearWeek(int yearNum, int weekNum, int dayOfWeek)
  7. getDateWeek(String date)
  8. getDay(long date, int startOfWeek, int increment)
  9. getDayAfterGivenDate(Date date, int dayOfWeek)