List of utility methods to do Calendar Day
Long | getDaysFromThen(Calendar aDate) get Days From Then long now = Calendar.getInstance().getTimeInMillis(); long then = aDate.getTimeInMillis(); long diffInMillis = now - then; return new Long(diffInMillis / 86400000); |
String | getDayStr(Calendar cal) get Day Str return cal.get(Calendar.DATE) > 9 ? "" + cal.get(Calendar.DATE) : "0" + cal.get(Calendar.DATE); |
String | getDayString(Calendar cal1) get Day String String day = cal1.get(Calendar.YEAR) + "-"; if (cal1.get(Calendar.MONTH) < 9) { day = day + "0" + (cal1.get(Calendar.MONTH) + 1) + "-"; if (cal1.get(Calendar.MONTH) >= 9) { day = day + (cal1.get(Calendar.MONTH) + 1) + "-"; if (cal1.get(Calendar.DAY_OF_MONTH) < 10) { ... |
String | getDayStringByCalendar(Calendar calendar) get Day String By Calendar int m = calendar.get(Calendar.MONTH) + 1; String month = ""; if (m >= 10) month = "" + m; else month = "0" + m; int d = calendar.get(Calendar.DAY_OF_MONTH); String day = ""; ... |
Calendar | getEndDay(Calendar cal) get End Day cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
cal.add(Calendar.HOUR_OF_DAY, 24);
return cal;
|
Calendar | getEndOfDay(Calendar c) Gets the end of the day based on the given Calendar . Calendar result = (Calendar) c.clone();
result.set(Calendar.HOUR_OF_DAY, 23);
result.set(Calendar.MINUTE, 59);
result.set(Calendar.SECOND, 59);
result.set(Calendar.MILLISECOND, 999);
return result;
|
Date | getEndOfDay(Date date, Calendar cal) get End Of Day cal.setTime(resetTime(date, cal));
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();
|
Calendar | getEndOfTodayAsCalendar() get End Of Today As Calendar return rollToEndOfDay(new Date()); |
Date | getFirstDay(Calendar cal) get First Day cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime();
|
int | getGregorianDay(Calendar cal) get Gregorian Day int year = cal.get(Calendar.YEAR) - 1600; int month = cal.get(Calendar.MONTH) + 1; if (month < 3) { month += 12; int day = cal.get(Calendar.DATE); int gregorianDay = (int) (6286 + (year * 365.25) - (year / 100) + (year / 400) + (30.6 * month) + 0.2 + day); ... |