Java Calendar Week getDayOfWeek(Calendar cal)

Here you can find the source of getDayOfWeek(Calendar cal)

Description

Quick hack to get day of week.

License

Open Source License

Parameter

Parameter Description
cal Calendar

Return

int

Declaration

private static int getDayOfWeek(Calendar cal) 

Method Source Code

//package com.java2s;
/*//from  w  w w.j  a va 2s .c  o m
 * Copyright 2000-2011 Enonic AS
 * http://www.enonic.com/license
 */

import java.util.Calendar;

public class Main {
    /**
     * Quick hack to get day of week. Can't get Calendar.get(Calendar.DAY_OF_WEEK) to work...
     *
     * @param cal Calendar
     * @return int
     */
    private static int getDayOfWeek(Calendar cal) {
        if (cal.get(Calendar.DAY_OF_WEEK) > 1) {
            return cal.get(Calendar.DAY_OF_WEEK) - 1;
        }

        // sunday is last day of week
        return 7;
    }
}

Related

  1. firstDayOfLastWeek(Calendar c)
  2. getADayOfWeek(Calendar day, int dayOfWeek)
  3. getDateOfLastDayOfWeekInMonth(Calendar calendar, int dayOfWeek)
  4. getDayFromPreviousWeek(Calendar requestDate)
  5. getDayOfWeek(Calendar c)
  6. getDayOfWeek(Calendar date)
  7. getDayOfWeekNumber(Calendar cal)
  8. getDayOfWeekString1(Calendar currentDate)
  9. getEndOfWeek(Calendar calendar, Date date, int dayStartOfWeek)