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

longgetJulianDay(Calendar currentDate)
Method getJulianDay.
long result = 0;
result = currentDate.get(Calendar.DAY_OF_YEAR);
return result;
intgetLastDay(Date targetDate, Calendar cal)
get Last Day
cal.setTime(targetDate);
return cal.getActualMaximum(Calendar.DATE);
DategetLastDayOfPreviousPeriod(int startDayOfPeriod, Calendar cal)
get Last Day Of Previous Period
int huidigeDagVdMaand = cal.get(Calendar.DAY_OF_MONTH);
if (huidigeDagVdMaand >= startDayOfPeriod) {
    int diff = huidigeDagVdMaand - startDayOfPeriod;
    cal.add(Calendar.DAY_OF_MONTH, -(diff + 1));
} else {
    cal.add(Calendar.DAY_OF_MONTH, -huidigeDagVdMaand);
    while (cal.get(Calendar.DAY_OF_MONTH) >= startDayOfPeriod) {
        cal.add(Calendar.DAY_OF_MONTH, -1);
...
CalendargetMonday(Calendar calendar)
get Monday
Calendar result = (Calendar) calendar.clone();
result.add(Calendar.DAY_OF_YEAR, -7);
result.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
result.set(Calendar.HOUR_OF_DAY, 24);
result.set(Calendar.MINUTE, 0);
result.set(Calendar.SECOND, 0);
result.set(Calendar.MILLISECOND, 0);
return result;
...
intgetNextDay(Calendar cal)
get Next Day
cal.add(Calendar.DATE, 1);
return cal.get(Calendar.DATE);
CalendargetNextDay(Calendar calendar, int day)
get Next Day
Calendar nextDay = (Calendar) calendar.clone();
nextDay.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + day);
return nextDay;
CalendargetNextMonday(Calendar date)
get Next Monday
Calendar result = null;
result = date;
do {
    result = (Calendar) result.clone();
    result.add(Calendar.DATE, 1);
} while (result.get(Calendar.DAY_OF_WEEK) != 2);
return result;
DategetNoonOfDay(Date day, Calendar cal)
Returns a Date set just to Noon, to the closest possible millisecond of the day.
if (day == null)
    day = new Date();
cal.setTime(day);
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.MINUTE, cal.getMinimum(Calendar.MINUTE));
cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
return cal.getTime();
...
CalendargetOneDayLaterCalendar(Date date)
get One Day Later Calendar
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, 1);
return cal;
FloatgetPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval)
get Principal After Compounding Interest
Float totalInterest = 0.0f;
Float interestEarned = 0.0f;
for (int i = 1; i <= depositPeriod; i++) {
    Integer daysInMonth = currentDate.getActualMaximum(Calendar.DATE);
    for (int j = 0; j < daysInMonth; j++) {
        interestEarned = (float) (principal * interestPerDay);
        totalInterest += interestEarned;
        if (compoundingInterval == 0) {
...