List of utility methods to do Calendar Year
Calendar | calendar(int year, int month, int date, int hourOfDay, int minute) calendar final Calendar cal = Calendar.getInstance(); cal.setLenient(false); cal.clear(); cal.set(year, month, date, hourOfDay, minute); return cal; |
Calendar | calendarFor(final int year, final int month, final int day, final int hour, final int minute) calendar For final Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
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, 0);
cal.set(Calendar.MILLISECOND, 0);
...
|
Calendar | calendarFor(int day, int month, int year) calendar For Calendar cal = Calendar.getInstance(Locale.US);
cal.set(calculateActualYear(month, year), (month < 0 ? (12 + (month % 12)) : month % 12), day);
return (cal);
|
Calendar | calendarOf(int year, int month, int day, int hour, int minute, int second, int millis) calendar Of Calendar calendar = calendarTodayOf(hour, minute, second, millis);
return setCalendarDate(calendar, year, month, day);
|
void | copyYearMonthDay(Calendar destCal, Calendar sourceCal) copy Year Month Day destCal.set(1, sourceCal.get(1)); destCal.set(2, sourceCal.get(2)); destCal.set(5, sourceCal.get(5)); |
Calendar | createAndValidateCalendar(int month, int day, int year) takes three small integers and creates a java.util.Calendar if (year < 10) year = 2000 + year; if (year < 100) year = 1900 + year; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(year, month - 1, day); return cal; ... |
double | getDecimalYear(Calendar calendar) Returns the year of the calendar object as a decimal value. return calendar.get(Calendar.YEAR) + (double) calendar.get(Calendar.DAY_OF_YEAR) / calendar.getActualMaximum(Calendar.DAY_OF_YEAR); |
int | getFiscalYear(Calendar calendar) get Fiscal Year int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); if (month > 9) { year = year + 1; return year; |
Integer | getIntYear(Calendar c) get Int Year int year = c.get(Calendar.YEAR); return year; |
String | getLastYear(Calendar cal) get Last Year cal.add(Calendar.YEAR, -1); return "" + cal.get(Calendar.YEAR); |