Here you can find the source of lastDayOfWeek(Calendar cal)
Parameter | Description |
---|---|
cal | a parameter |
public static int lastDayOfWeek(Calendar cal)
//package com.java2s; /******************************************************************************* * Copyright (c) Nov 2, 2012 NetXForge.//w ww .j a va2 s. com * * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/> * * Contributors: Christophe Bouhier - initial API and implementation and/or * initial documentation *******************************************************************************/ import java.util.Calendar; public class Main { /** * Get the last day of the week respecting the first day of the week for the * provided Calendar. * * @param cal * @return */ public static int lastDayOfWeek(Calendar cal) { final int firstDayOfWeek = cal.getFirstDayOfWeek(); final int lastDayOfWeek; if (firstDayOfWeek != 1) { lastDayOfWeek = firstDayOfWeek - 1; // One before the first day... } else { lastDayOfWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK); // Expect } return lastDayOfWeek; } }