Java Week Day getDayOfWeek(Date date)

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

Description

get Day Of Week

License

Apache License

Declaration

public static int getDayOfWeek(Date date) 

Method Source Code

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

import java.util.*;

public class Main {

    public static int getDayOfWeek(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date.getTime());
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        int rel = 0;
        switch (dayOfWeek) {
        case Calendar.MONDAY:
            rel = 1;/*w  w w  .  java  2 s .  c o  m*/
            break;
        case Calendar.TUESDAY:
            rel = 2;
            break;
        case Calendar.WEDNESDAY:
            rel = 3;
            break;
        case Calendar.THURSDAY:
            rel = 4;
            break;
        case Calendar.FRIDAY:
            rel = 5;
            break;
        case Calendar.SATURDAY:
            rel = 6;
            break;
        default:
            rel = 7;
            break;
        }
        return rel;
    }
}

Related

  1. getDayOfTheWeekFromNow(int nDays)
  2. getDayOfWeek()
  3. getDayOfWeek(Date date)
  4. getDayOfWeek(Date date)
  5. getDayOfWeek(Date date)
  6. getDayOfWeek(Date date)
  7. getDayOfWeek(Date date, int day)
  8. getDayOfWeek(Date dt)
  9. getDayOfWeek(Date start, int day)