Java Day of Week 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) throws ParseException 

Method Source Code

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

import java.text.ParseException;

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

public class Main {

    public static int getDayOfWeek(Date date) throws ParseException {

        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/* w ww  . j ava 2s  . c o m*/
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0) {
            w = 1;
        }

        if (w == 0) {
            w = 7;
        }

        return w;

        //      return get_week(date);
    }
}

Related

  1. getDateOfYearWeek(int yearNum, int weekNum, int dayOfWeek)
  2. getDateWeek(String date)
  3. getDay(long date, int startOfWeek, int increment)
  4. getDayAfterGivenDate(Date date, int dayOfWeek)
  5. getDayOfWeek()
  6. getDayOfWeek(int _year, int _month, int _day)
  7. getDayOfWeek(int year, int month, int day)
  8. getDayOfWeek(int year, int month, int day)
  9. getDayOfWeek(String date, String pattern)