Java Week Day getDayWithWeek(Date date)

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

Description

get Day With Week

License

Apache License

Declaration

public static int getDayWithWeek(Date date) 

Method Source Code

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

import java.util.*;

public class Main {

    public static int getDayWithWeek(Date date) {
        int day = getNumberFromDate(date, Calendar.DAY_OF_WEEK);
        if (day == 1) {
            return 7;
        }/*from w w w.  j  a  va  2s.  c  o m*/
        return day - 1;
    }

    public static int getNumberFromDate(Date date, int field) {
        Calendar cal = Calendar.getInstance();
        if (date != null) {
            cal.setTime(date);
        }
        return cal.get(field);
    }
}

Related

  1. getDayOfWeek(String year, String month, String day)
  2. getDayOfWeekAbbreviation(int day)
  3. getDayOfWeekAbreviated(Date d)
  4. getDayOfWeekShortString(Date date)
  5. getDaysExceptWeekend(String from, String to)
  6. getENWeekDay()
  7. getFirstday_Lastday_Week()
  8. getFirstDayOfLastWeek(Date date)
  9. getFirstDayOfWeek()