List of utility methods to do Calendar Day
long | getJulianDay(Calendar currentDate) Method getJulianDay. long result = 0; result = currentDate.get(Calendar.DAY_OF_YEAR); return result; |
int | getLastDay(Date targetDate, Calendar cal) get Last Day cal.setTime(targetDate);
return cal.getActualMaximum(Calendar.DATE);
|
Date | getLastDayOfPreviousPeriod(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); ... |
Calendar | getMonday(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;
...
|
int | getNextDay(Calendar cal) get Next Day cal.add(Calendar.DATE, 1);
return cal.get(Calendar.DATE);
|
Calendar | getNextDay(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;
|
Calendar | getNextMonday(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; |
Date | getNoonOfDay(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(); ... |
Calendar | getOneDayLaterCalendar(Date date) get One Day Later Calendar Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, 1);
return cal;
|
Float | getPrincipalAfterCompoundingInterest(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) { ... |