Here you can find the source of calendarOf(int year, int month, int day, int hour, int minute, int second, int millis)
public static Calendar calendarOf(int year, int month, int day, int hour, int minute, int second, int millis)
//package com.java2s; import java.util.Calendar; public class Main { public static Calendar calendarOf(int year, int month, int day, int hour, int minute, int second, int millis) { Calendar calendar = calendarTodayOf(hour, minute, second, millis); return setCalendarDate(calendar, year, month, day); }/*from w w w . j a v a2 s. c om*/ public static Calendar calendarTodayOf(int hour, int minute, int second, int millis) { Calendar calendar = Calendar.getInstance(); return setCalendarTime(calendar, hour, minute, second, millis); } public static Calendar calendarTodayOf(int hour, int minute, int second) { return calendarTodayOf(hour, minute, second, 0); } public static Calendar calendarTodayOf(int hour, int minute) { return calendarTodayOf(hour, minute, 0, 0); } public static Calendar setCalendarDate(Calendar calendar, int year, int month, int day) { calendar.set(Calendar.YEAR, year); //Calendar.JANUARY + month - 1 == month - 1 calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); return calendar; } public static Calendar setCalendarTime(Calendar calendar, int hour, int minute, int second, int millis) { calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, millis); return calendar; } }