Java Day of Week getWeek(Date today)

Here you can find the source of getWeek(Date today)

Description

get Week

License

Open Source License

Declaration

public static int getWeek(Date today) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static int getWeek(Date today) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);/* w w  w.  jav  a  2  s .c  om*/
        //        return calendar.get(Calendar.DAY_OF_WEEK)-1;
        switch (calendar.get(Calendar.DAY_OF_WEEK)) {
        case 1:
            return 0;
        case 2:
            return 1;
        case 3:
            return 2;
        case 4:
            return 3;
        case 5:
            return 4;
        case 6:
            return 5;
        case 7:
            return 6;
        }
        return 0;
    }
}

Related

  1. getSundayOfWeek(Date date)
  2. getThisweekFirst(Date early)
  3. getWeek(Date date)
  4. getWeek(Date date)
  5. getWeek(Date dateParam)
  6. getWeek(java.util.Date date)
  7. getWeek(java.util.Date today)
  8. getWeekBegin(Date date)
  9. getWeekCategory(final Date date)