Android Day of Week Get 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.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static int getDayOfWeek(String year, String month, String day) {
        Calendar cal = new GregorianCalendar(new Integer(year).intValue(),
                new Integer(month).intValue() - 1,
                new Integer(day).intValue());
        return cal.get(Calendar.DAY_OF_WEEK);
    }//from   w w w.j a  va2  s  .  c  o  m

    public static int getDayOfWeek(String date) {
        String[] temp = null;
        if (date.indexOf("/") > 0) {
            temp = date.split("/");
        }
        if (date.indexOf("-") > 0) {
            temp = date.split("-");
        }
        return getDayOfWeek(temp[0], temp[1], temp[2]);
    }

    public static int getDayOfWeek(Date date) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(date);
        return cal.get(Calendar.DAY_OF_WEEK);
    }
}

Related

  1. getDayOfWeekString(int dayOfWeek, int abbrev)
  2. getDayofWeekInMonth(String year, String month, String weekOfMonth, String dayOfWeek)
  3. getDayOfWeek(String year, String month, String day)
  4. getDayOfWeek(String date)
  5. getFirstDayOfWeek()
  6. getDayOfTheWeek(Date date)
  7. getDayOfWeekZeroIndexed(Date dateTime)
  8. getReadableWeekDay(int day)