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

LonggetDaysFromThen(Calendar aDate)
get Days From Then
long now = Calendar.getInstance().getTimeInMillis();
long then = aDate.getTimeInMillis();
long diffInMillis = now - then;
return new Long(diffInMillis / 86400000);
StringgetDayStr(Calendar cal)
get Day Str
return cal.get(Calendar.DATE) > 9 ? "" + cal.get(Calendar.DATE) : "0" + cal.get(Calendar.DATE);
StringgetDayString(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) {
...
StringgetDayStringByCalendar(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 = "";
...
CalendargetEndDay(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;
CalendargetEndOfDay(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;
DategetEndOfDay(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();
CalendargetEndOfTodayAsCalendar()
get End Of Today As Calendar
return rollToEndOfDay(new Date());
DategetFirstDay(Calendar cal)
get First Day
cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime();
intgetGregorianDay(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);
...