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

CalendargetCanonicalDay(Calendar cal)
Returns the canonical day calendar for a given calendar, which is the first millisecond of the day (2008/03/07 15:23:32 992ms --> 2008/03/07 0:0:0 0ms)
Calendar ret = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
        cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
ret.set(Calendar.MILLISECOND, 0);
ret.setTimeZone(cal.getTimeZone());
return ret;
CalendargetCanonicalDayFrom(Calendar day, int daysFrom)
Returns the canonical day of the day specified in days from another date
Calendar ret = getCanonicalDay(day);
ret.add(Calendar.DAY_OF_YEAR, daysFrom);
return getCanonicalDay(ret);
DategetCleanDay(Calendar c)
get Clean Day
c.set(11, 0);
c.clear(12);
c.clear(13);
c.clear(14);
return c.getTime();
intgetCurDay(Calendar calendar)
get Cur Day
if (calendar == null) {
    return getCurDay();
return calendar.get(Calendar.DAY_OF_MONTH);
StringgetDay(Calendar cal)
get Day
return strLen(String.valueOf(cal.get(Calendar.DAY_OF_MONTH)), 2);
intgetDay(Calendar calendar)
get Day
return calendar.get(Calendar.DAY_OF_MONTH);
intgetDay(Calendar calendar)
get Day
return calendar.get(Calendar.DAY_OF_MONTH);
CalendargetDayEndCalendar(Calendar cal)
get Day End Calendar
Date date = cal.getTime();
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(date);
endCalendar.set(Calendar.HOUR, 11);
endCalendar.set(Calendar.HOUR_OF_DAY, 23);
endCalendar.set(Calendar.MINUTE, 59);
endCalendar.set(Calendar.SECOND, 59);
return endCalendar;
...
StringgetDayName(Calendar cal)
get Day Name
String month = dayName[cal.get(Calendar.DAY_OF_WEEK) - 1];
return month;
intgetDayOfPeriod(Calendar cal, long timems)
get Day Of Period
int rtn = 0;
cal.clear();
cal.setTime(new java.util.Date(timems));
Calendar currCal = Calendar.getInstance();
currCal.setTime(new java.util.Date(timems));
while (cal.get(Calendar.YEAR) >= _baseCal.get(Calendar.YEAR)) {
    if (cal.get(Calendar.YEAR) == currCal.get(Calendar.YEAR)) {
        rtn += currCal.get(Calendar.DAY_OF_YEAR);
...