Java Utililty Methods Calendar Day

List of utility methods to do Calendar Day

Description

The list of methods to do Calendar Day are organized into topic(s).

Method

CalendardayMarkToCalendar(int day)
day Mark To Calendar
Calendar calendar = Calendar.getInstance();
calendar.set(getYearOfDayMark(day), getMonthOfDayMark(day) - 1, getDayOfDayMark(day), 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar;
CalendardayPrecision(Calendar calendar)
Remove precision from a calendar so that it represents just a day.
Calendar cal = Calendar.getInstance();
cal.setTime(calendar.getTime());
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR_OF_DAY, 0);
return cal;
intdaysFromBinStart(Calendar date)
days From Bin Start
return numberOfDaysBetween(startDateForBinning, date);
longdaysSinceTheJesus(Calendar cal)
days Since The Jesus
long year = cal.get(Calendar.YEAR);
long dayOfYear = cal.get(Calendar.DAY_OF_YEAR);
return year * 365 + (year + 3) / 4 - (year + 99) / 100 + (year + 399) / 400 + dayOfYear - 1;
CalendardayStart(Calendar date)
Returns the start of the day (00:00:00:000) for the specified date.
Calendar c = (Calendar) date.clone();
c.set(Calendar.HOUR_OF_DAY, c.getMinimum(Calendar.HOUR_OF_DAY));
c.set(Calendar.MINUTE, c.getMinimum(Calendar.MINUTE));
c.set(Calendar.SECOND, c.getMinimum(Calendar.SECOND));
c.set(Calendar.MILLISECOND, c.getMinimum(Calendar.MILLISECOND));
return c;
CalendardayStart(final Calendar cal)
day Start
cal.get(Calendar.HOUR_OF_DAY); 
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.get(Calendar.HOUR_OF_DAY); 
return cal;
voiddecreaseByDay(final Calendar calendar)
Decreases calendar date by one day.
changeByDays(calendar, -1);
voidendOfDay(Calendar calendar)
Adjust the given calendar to the last millisecond of the specified date.
calendar.add(Calendar.DATE, 1);
startOfDay(calendar);
calendar.add(Calendar.MILLISECOND, -1);
IntegergetAge(Calendar dateOfBirth, Calendar onThisDay)
This method will calculate the age of the person on the given date.
return (yearDifference(dateOfBirth, onThisDay));
CalendargetBeginDay(Calendar cal)
get Begin Day
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal;