Java Day of Week getWeekOfDate(Date dt)

Here you can find the source of getWeekOfDate(Date dt)

Description

get Week Of Date

License

Apache License

Declaration

public static String getWeekOfDate(Date dt) 

Method Source Code

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

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

public class Main {

    public static String getWeekOfDate(Date dt) {
        String[] weekDays = { "7", "1", "2", "3", "4", "5", "6" };
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);/*from   w w w. j  ava  2  s. c o  m*/
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;
        return weekDays[w];
    }
}

Related

  1. getWeekNum(Date date)
  2. getWeekNumber(Date date)
  3. getWeekNumber(Date date, Integer day)
  4. getWeekNumberFromDate(Date date)
  5. getWeekNumOfYear(Date date)
  6. getWeekOfDay(Date date)
  7. getWeekOfMonth(Date date)
  8. getWeekOfMonth(final Date date)
  9. getWeekOfMonthFirstDay(Date dt)