Here you can find the source of endOfMonth(Calendar calendar)
Parameter | Description |
---|---|
calendar | a parameter |
public static void endOfMonth(Calendar calendar)
//package com.java2s; /*//ww w . j a v a 2 s. c o m * #%L * The AIBench Plugin Manager Plugin * %% * Copyright (C) 2006 - 2016 Daniel Glez-Pe?a and Florentino Fdez-Riverola * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser 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 Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ import java.util.Calendar; import java.util.Date; public class Main { /** * Adjusts the calendar to the end of the current month. * That is the last day of the month with all time-fields * at max. * * @param calendar */ public static void endOfMonth(Calendar calendar) { // start of next month calendar.add(Calendar.MONTH, 1); startOfMonth(calendar); // one millisecond back calendar.add(Calendar.MILLISECOND, -1); } /** * Adjusts the calendar to the start of the current month. * That is, first day of the month with all time fields cleared. * @param calendar */ public static void startOfMonth(Calendar calendar) { calendar.set(Calendar.DAY_OF_MONTH, 1); startOfDay(calendar); } /** * Adjust the given calendar to the first millisecond of the given date. * that is all time fields cleared. The Date of the adjusted Calendar is * returned. * * @param calendar calendar to adjust. * @param date the Date to use. * @return the start of the day of the given date */ public static Date startOfDay(Calendar calendar, Date date) { calendar.setTime(date); startOfDay(calendar); return calendar.getTime(); } /** * Adjust the given calendar to the first millisecond of the current day. * that is all time fields cleared. * * @param calendar calendar to adjust. */ public static void startOfDay(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); } }