List of utility methods to do Calendar Year
int | getYearForWeek(final Calendar cal) found here: http://www.odi.ch/prog/design/datetime.php final int year = cal.get(Calendar.YEAR); final int week = cal.get(Calendar.WEEK_OF_YEAR); final int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); if (week == 1 && dayOfMonth > 20) { return year + 1; if (week >= 52 && dayOfMonth < 10) { return year - 1; ... |
ArrayList | getYearList(Calendar currDate) get Year List int prmBeforeCnt = 5; int prmAfterCnt = 5; return getYearList(currDate, prmBeforeCnt, prmAfterCnt); |
boolean | isBeforeDay(Calendar date1, Calendar date2, boolean ignoreYear) Returns true if the first date is before the second comparing day, month, and year.
int year1 = date1.get(Calendar.YEAR); int year2 = date2.get(Calendar.YEAR); int month1 = date1.get(Calendar.MONTH); int month2 = date2.get(Calendar.MONTH); int day1 = date1.get(Calendar.DAY_OF_MONTH); int day2 = date2.get(Calendar.DAY_OF_MONTH); if (!ignoreYear && year1 < year2) { return true; ... |
boolean | isSameDay(Calendar date1, Calendar date2, boolean ignoreYear) Returns true if the two specified dates are on the same day of the same month in the same year.
return date1.get(Calendar.DAY_OF_MONTH) == date2.get(Calendar.DAY_OF_MONTH)
&& date1.get(Calendar.MONTH) == date2.get(Calendar.MONTH)
&& (ignoreYear || date1.get(Calendar.YEAR) == date2.get(Calendar.YEAR));
|
boolean | isSameDayOfYear(Calendar calendar1, Calendar calendar2) is Same Day Of Year return (getYear(calendar1) == getYear(calendar2)) && (getDay(calendar1) == getDay(calendar2));
|
boolean | isSameWeekOfYear(Calendar calendar1, Calendar calendar2) is Same Week Of Year boolean sameWeek = false; if (getYear(calendar1) == getYear(calendar2)) { if (getWeek(calendar1) == getWeek(calendar2)) sameWeek = true; else { Calendar calendar1Temp = (Calendar) calendar1.clone(); Calendar calendar2Temp = (Calendar) calendar2.clone(); ... |
boolean | isToThisDayOrLater(int year, int month, int day, java.util.Calendar start, java.util.Calendar end) is To This Day Or Later return (((start.get(java.util.Calendar.YEAR) < year) && (end.get(java.util.Calendar.YEAR) == year))
&& (end.get(java.util.Calendar.MONTH) >= month)
&& (end.get(java.util.Calendar.DAY_OF_MONTH) >= day));
|
boolean | isWithinYears(int year, java.util.Calendar start, java.util.Calendar end) is Within Years return ((start.get(java.util.Calendar.YEAR) < year) && (end.get(java.util.Calendar.YEAR) > year));
|
GregorianCalendar | parseCalendar(int year, int month, double day, TimeZone zone) Parses a date assuming all arguments are based on a Gregorian or Julian calendar. double hour = (day % 1) * 24; double minute = (hour % 1) * 60; double second = (minute % 1) * 60; double millisecond = (second % 1) * 1000; return parseCalendar(year, month, (int) day, (int) hour, (int) minute, (int) second, (int) Math.round(millisecond), zone); |
boolean | sameYear(Calendar one, Calendar two) Returns true if the two given calendars are dated on the same year. return one.get(Calendar.YEAR) == two.get(Calendar.YEAR);
|