List of utility methods to do Calendar Day
void | setStartTimeOfDay(Calendar calender) set Start Time Of Day calender.set(Calendar.HOUR_OF_DAY, calender.getActualMinimum(Calendar.HOUR_OF_DAY)); calender.set(Calendar.MINUTE, calender.getActualMinimum(Calendar.MINUTE)); calender.set(Calendar.SECOND, calender.getActualMinimum(Calendar.SECOND)); calender.set(Calendar.MILLISECOND, calender.getActualMinimum(Calendar.MILLISECOND)); |
Calendar | setToBeginningOfDay(Calendar cal) This method will set the calenders hour/min/sec//milliseconds all to 0. cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.getTimeInMillis();
return (cal);
|
void | setToStartOfDay(Calendar start) set To Start Of Day start.set(GregorianCalendar.HOUR_OF_DAY, 0); start.set(GregorianCalendar.MINUTE, 0); |
void | setToStartTimeOfTheDay(Calendar c) set To Start Time Of The Day c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); |
void | startOfDay(Calendar calendar) Adjust the given calendar to the first millisecond of the current day. calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); |
long | toCountWorkDays(GregorianCalendar start, GregorianCalendar end) to Count Work Days long result = 0; GregorianCalendar startDate = new GregorianCalendar(); GregorianCalendar endDate = new GregorianCalendar(); startDate.setTime(start.getTime()); endDate.setTime(end.getTime()); if ((startDate.get(GregorianCalendar.DAY_OF_WEEK) % 7) <= 1) { startDate.add(GregorianCalendar.DATE, 2 - (startDate.get(GregorianCalendar.DAY_OF_WEEK) % 7)); if ((endDate.get(GregorianCalendar.DAY_OF_WEEK) % 7) <= 1) { endDate.add(GregorianCalendar.DATE, -1 - (endDate.get(GregorianCalendar.DAY_OF_WEEK) % 7)); long totaldays = toDayInterval(startDate, endDate); int s = endDate.get(GregorianCalendar.DAY_OF_WEEK) - startDate.get(GregorianCalendar.DAY_OF_WEEK); if (s < 0) { s += 5; if (totaldays % 7 != 0) result = s + (totaldays / 7) * 5 + 1; else result = (totaldays / 7) * 5; if (result < 0) { result = 0; return result; |
Calendar | todayCalendar() today Calendar Calendar cal = new GregorianCalendar(); clearTime(cal); return cal; |
Calendar | toEndOfDayCalendar(Date date) to End Of Day Calendar Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
return cal;
|
void | toNextWorkDay(Calendar cal) to Next Work Day if (isRestDay(cal)) {
cal.add(Calendar.DATE, 1);
toNextWorkDay(cal);
|
Calendar | trimToDay(Calendar calendar) Trims the specified calendar to the day by resetting the following attributes:
Calendar cloneCal = (Calendar) calendar.clone();
cloneCal.set(Calendar.HOUR_OF_DAY, 0);
cloneCal.set(Calendar.MINUTE, 0);
cloneCal.set(Calendar.SECOND, 0);
cloneCal.set(Calendar.MILLISECOND, 0);
return cloneCal;
|