Here you can find the source of setCalendarFields(Calendar cal, int year, int month, int day, int hour, int minute, int second, int millis)
private static void setCalendarFields(Calendar cal, int year, int month, int day, int hour, int minute, int second, int millis)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { private static void setCalendarFields(Calendar cal, int year, int month, int day, int hour, int minute, int second, int millis) { if (year <= 0) { cal.set(Calendar.ERA, GregorianCalendar.BC); cal.set(Calendar.YEAR, 1 - year); } else {//w ww . j av a 2 s. c o m cal.set(Calendar.ERA, GregorianCalendar.AD); cal.set(Calendar.YEAR, year); } // january is 0 cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.set(Calendar.SECOND, second); cal.set(Calendar.MILLISECOND, millis); } }