List of utility methods to do Calendar Day
Calendar | dayMarkToCalendar(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;
|
Calendar | dayPrecision(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;
|
int | daysFromBinStart(Calendar date) days From Bin Start return numberOfDaysBetween(startDateForBinning, date);
|
long | daysSinceTheJesus(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; |
Calendar | dayStart(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;
|
Calendar | dayStart(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;
|
void | decreaseByDay(final Calendar calendar) Decreases calendar date by one day. changeByDays(calendar, -1); |
void | endOfDay(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); |
Integer | getAge(Calendar dateOfBirth, Calendar onThisDay) This method will calculate the age of the person on the given date. return (yearDifference(dateOfBirth, onThisDay));
|
Calendar | getBeginDay(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;
|