Here you can find the source of isMatchWeek(Date date, int week)
public static boolean isMatchWeek(Date date, int week)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* ww w . j av a 2s.c o m*/ * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { public static boolean isMatchWeek(Date date, int week) { return getWeekOfDate(date) == week; } public static boolean isMatchWeek(Date date, Integer[] weeks) { int len = weeks.length; for (int m = 0; m < len; m++) { int week = weeks[m]; if (isMatchWeek(date, week)) return true; } return false; } public static int getWeekOfDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return (calendar.get(Calendar.DAY_OF_WEEK) - 1) == 0 ? 7 : calendar.get(Calendar.DAY_OF_WEEK) - 1; } }