Java Day of Week getWeekStartDateBeforeCurrent(int weekNum, Date current)

Here you can find the source of getWeekStartDateBeforeCurrent(int weekNum, Date current)

Description

get Week Start Date Before Current

License

Apache License

Declaration

public static long getWeekStartDateBeforeCurrent(int weekNum, Date current) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;

public class Main {

    public static long getWeekStartDateBeforeCurrent(int weekNum, Date current) {
        // delete by lijun begin
        // return getLatestStartOfWeek(current) -
        // ((long)weekNum*7*24*60*60*1000);
        // delete by lijun end

        // add by lijun begin
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(current);/*from ww  w .j a  v a2 s  .  c om*/
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        calendar.add(Calendar.DAY_OF_MONTH, -weekNum * 7);

        return calendar.getTimeInMillis();
        // add by lijun end
    }
}

Related

  1. getWeekOfYear(Date date)
  2. getWeekOfYear(String date)
  3. getWeeksBetweenDate(Date begin, Date end)
  4. getWeekStart(Date date)
  5. getWeekStart(Date date)
  6. getWeekth(String sDate)
  7. getYearOfWeek(Date date)
  8. incWeek(java.util.Date date, int amount, Locale locale)
  9. isMatchWeek(Date date, int week)