Java Day of Week getIsoDayOfWeek(Date date)

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

Description

Return the day of week.

License

Open Source License

Parameter

Parameter Description
date the date object which day of week should be calculated

Return

the day of the week, Monday as 1 to Sunday as 7

Declaration

public static int getIsoDayOfWeek(Date date) 

Method Source Code

//package com.java2s;
/*//w w  w.  j a  v a 2 s  . com
 * Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License,
 * Version 1.0, and under the Eclipse Public License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: Robert Rathsack (firstName dot lastName at gmx dot de)
 */

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

public class Main {
    /**
     * Return the day of week. Week starts at Monday.
     *
     * @param date the date object which day of week should be calculated
     * @return the day of the week, Monday as 1 to Sunday as 7
     */
    public static int getIsoDayOfWeek(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date.getTime());
        int val = cal.get(Calendar.DAY_OF_WEEK) - 1;
        return val == 0 ? 7 : val;
    }
}

Related

  1. getFirstMonthWeek(Date month)
  2. getFirstWeekdayBetween(Date fromDate, Date toDate, int dayOfWeek)
  3. getFirstWeekofMonth(Date date1)
  4. getIntervalIncludeWeekend(Date date)
  5. getISO8601WeekOfYear(Date date)
  6. getIsoWeek(java.util.Date date)
  7. getLastDayFromLastWeek(Date d)
  8. getLastDayOfTheWeek(Date date)
  9. getLastDayOfWeek(Date date)