Java Week Calculate getBounceDatesOfWeek(Date date)

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

Description

get Bounce Dates Of Week

License

Open Source License

Parameter

Parameter Description
date a parameter

Return

array of two date elements, first is the first day of week, and the second is the end week date

Declaration

public static Date[] getBounceDatesOfWeek(Date date) 

Method Source Code

//package com.java2s;
/**/*from w w  w  .j av a  2 s  . co  m*/
 * This file is part of mycollab-core.
 *
 * mycollab-core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * mycollab-core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with mycollab-core.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.*;

public class Main {
    /**
     * @param date
     * @return array of two date elements, first is the first day of week, and
     * the second is the end week date
     */
    public static Date[] getBounceDatesOfWeek(Date date) {
        Calendar calendar = new GregorianCalendar();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTime(date);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        Date begin = calendar.getTime();

        calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
        Date end = calendar.getTime();
        return new Date[] { begin, end };
    }
}

Related

  1. alignWeek(Calendar timestamp)
  2. diffWeeks(Date start, Date end)
  3. getCurrentWeekNum(Date startDate, Date endDate)
  4. getCurrWeek()
  5. getEndOfWeek(Calendar cal)
  6. getSeqWeek()