List of utility methods to do Calendar Day
Calendar | getCanonicalDay(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; |
Calendar | getCanonicalDayFrom(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);
|
Date | getCleanDay(Calendar c) get Clean Day c.set(11, 0);
c.clear(12);
c.clear(13);
c.clear(14);
return c.getTime();
|
int | getCurDay(Calendar calendar) get Cur Day if (calendar == null) { return getCurDay(); return calendar.get(Calendar.DAY_OF_MONTH); |
String | getDay(Calendar cal) get Day return strLen(String.valueOf(cal.get(Calendar.DAY_OF_MONTH)), 2);
|
int | getDay(Calendar calendar) get Day return calendar.get(Calendar.DAY_OF_MONTH);
|
int | getDay(Calendar calendar) get Day return calendar.get(Calendar.DAY_OF_MONTH);
|
Calendar | getDayEndCalendar(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;
...
|
String | getDayName(Calendar cal) get Day Name String month = dayName[cal.get(Calendar.DAY_OF_WEEK) - 1];
return month;
|
int | getDayOfPeriod(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); ... |