Here you can find the source of getStartDates(Date baseDate, int weekNum)
Description:Get start date of weeks specified by parameter weekNum beginning from the week
specified by parameter baseDateParameter | Description |
---|---|
Date | baseDate start point of calculation |
public static List<Date> getStartDates(Date baseDate, int weekNum)
//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; } }