Java Calendar Week getFirstOfMonthDayOfWeek(GregorianCalendar aCalendar)

Here you can find the source of getFirstOfMonthDayOfWeek(GregorianCalendar aCalendar)

Description

Gets the day of the week for the first day of the month.

License

Open Source License

Parameter

Parameter Description
aCalendar a GregorianCalendar to query

Return

a value like get(DAY_OF_WEEK) where the first day of the week (E.g. Sunday) is 1.

Declaration

public static int getFirstOfMonthDayOfWeek(GregorianCalendar aCalendar) 

Method Source Code

//package com.java2s;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    /**/*from  www . ja  va 2s  .  c o  m*/
     * Gets the day of the week for the first day of the month.
     *
     * @param aCalendar a GregorianCalendar to query
     *
     * @return a value like get(DAY_OF_WEEK) where the first day of the week
     * (E.g. Sunday) is 1.
     */
    public static int getFirstOfMonthDayOfWeek(GregorianCalendar aCalendar) {
        int currDom = aCalendar.get(Calendar.DAY_OF_MONTH);
        aCalendar.set(Calendar.DAY_OF_MONTH, 1);

        // 1 is Sunday (Hmmm... 0 is January, 1 is Sunday ??????)
        int firstDowInMonth = aCalendar.get(Calendar.DAY_OF_WEEK);
        aCalendar.set(Calendar.DAY_OF_MONTH, currDom);
        return firstDowInMonth;
    }
}

Related

  1. getDayOfWeekString1(Calendar currentDate)
  2. getEndOfWeek(Calendar calendar, Date date, int dayStartOfWeek)
  3. getFirstDateInMonthForDayOfWeek(Calendar cal, final int dayOfWeek)
  4. getFirstDayOfWeek(Calendar cal)
  5. getFirstDayOfWeek(Calendar calendar)
  6. getImmediateDayOfWeek(Calendar current, int dayOfWeek)
  7. getLastDayOfWeek(Calendar cal)
  8. getLastDayOfWeek(Calendar cal)
  9. getWeek(Calendar calendar)