Here you can find the source of setDate(Calendar cal, int month, int date, boolean endOfDay)
static void setDate(Calendar cal, int month, int date, boolean endOfDay)
//package com.java2s; //License from project: LGPL import java.util.Calendar; public class Main { static void setDate(Calendar cal, int month, int date, boolean endOfDay) { cal.clear();/*from ww w . j a v a 2 s .c om*/ cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); cal.set(Calendar.MONTH, month); cal.set(Calendar.DATE, date); if (endOfDay) { cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); } } }