Here you can find the source of setDate(Calendar calendar, int month, int date)
Parameter | Description |
---|---|
calendar | the Calendar 's instance. |
month | the month. |
date | the day of the month. |
private static void setDate(Calendar calendar, int month, int date)
//package com.java2s; /*/* w w w .ja v a2s .co m*/ * Copyright (C) 2014 Celestibytes * * 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 Public License for more * details. */ import java.util.Calendar; public class Main { /** * Sets the given {@link Calendar}'s instance to a specific date. * * @param calendar * the {@link Calendar}'s instance. * @param month * the month. * @param date * the day of the month. */ private static void setDate(Calendar calendar, int month, int date) { calendar.clear(); calendar.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } }