Java Day of Week getWeek(Date date)

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

Description

get Week

License

Apache License

Parameter

Parameter Description
date a parameter

Return

1,2,3,4,5,6,7

Declaration

public static Integer getWeek(Date date) 

Method Source Code

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

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

public class Main {
    /***// w w  w. j  a v a2  s  .c o m
      * @param date
      * @return 1,2,3,4,5,6,7
      */
    private static int[] chweek = new int[] { 0, 7, 1, 2, 3, 4, 5, 6 };

    /**
      * @param date
      * @return 1,2,3,4,5,6,7
      */
    public static Integer getWeek(Date date) {
        if (date == null)
            return null;
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return chweek[c.get(Calendar.DAY_OF_WEEK)];
    }
}

Related

  1. getStartDates(Date baseDate, int weekNum)
  2. getSundayDate(int week, int year)
  3. getSundayOfWeek(Date date)
  4. getThisweekFirst(Date early)
  5. getWeek(Date date)
  6. getWeek(Date dateParam)
  7. getWeek(Date today)
  8. getWeek(java.util.Date date)
  9. getWeek(java.util.Date today)