Here you can find the source of createCalendar(int year, int month, int day, int hour, int minute, int second, boolean ceiling)
public static Calendar createCalendar(int year, int month, int day, int hour, int minute, int second, boolean ceiling)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.TimeZone; public class Main { /**// w ww . j a va 2 s. com * Creates a calendar in the given year. Year must be specified, but all * other fields can be -1 if unknown. If -1, they're either the greatest of * least value of the calendar's current state depending on the value of * ceiling. */ public static Calendar createCalendar(int year, int month, int day, int hour, int minute, int second, boolean ceiling) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(Calendar.YEAR, year); fillInField(Calendar.MONTH, month - 1, ceiling, cal); fillInField(Calendar.DAY_OF_MONTH, day, ceiling, cal); fillInField(Calendar.HOUR_OF_DAY, hour, ceiling, cal); fillInField(Calendar.MINUTE, minute, ceiling, cal); fillInField(Calendar.SECOND, second, ceiling, cal); fillInField(Calendar.MILLISECOND, -1, ceiling, cal); return cal; } public static void fillInField(int field, int value, boolean ceiling, Calendar cal) { if (value >= 0) { cal.set(field, value); } else if (ceiling) { cal.set(field, cal.getActualMaximum(field)); } else { cal.set(field, cal.getActualMinimum(field)); } } }