Java Day of Week getStartDates(Date baseDate, int weekNum)

Here you can find the source of getStartDates(Date baseDate, int weekNum)

Description

Description:Get start date of weeks specified by parameter weekNum beginning from the week

specified by parameter baseDate

License

Open Source License

Parameter

Parameter Description
Date baseDate start point of calculation

Return

List a list of start date of weeks

Declaration

public static List<Date> getStartDates(Date baseDate, int weekNum) 

Method Source Code

//package com.java2s;
/*//from w w  w.ja v  a  2 s . c  om
 * $RCSfile: DatetimeUtil,v $$
 * $Revision: 1.0  $
 * $Date: 2011  $
 *
 * Copyright (C) 2011 GyTech, Inc. All rights reserved.
 *
 * This software is the proprietary information of GyTech, Inc.
 * Use is subject to license terms.
 */

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main {
    /**
     * <p>Description:Get start date of weeks specified by parameter weekNum beginning from the week</p>
     * specified by parameter baseDate
     * @param Date baseDate start point of calculation
     * @param int weekNum number of weeks
     * @return List a list of start date of weeks
     */
    public static List<Date> getStartDates(Date baseDate, int weekNum) {
        List<Date> result = new ArrayList<Date>();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(baseDate);
        result.add(new Date(baseDate.getTime()));

        for (int i = 0; i < weekNum - 1; i++) {
            calendar.add(Calendar.DAY_OF_YEAR, 7);
            result.add(calendar.getTime());
        }

        return result;
    }
}

Related

  1. getSatDayOfWeek(Date date)
  2. getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second)
  3. getSeqWeek(String date)
  4. getSeqWeekByMonth(Date currDate)
  5. getStartDate(int year, int week)
  6. getSundayDate(int week, int year)
  7. getSundayOfWeek(Date date)
  8. getThisweekFirst(Date early)
  9. getWeek(Date date)