Hello,
This is a advanced code, please go through it and understand as much as you can.
Code:
public boolean isAfterPayDay(DateTime dttm) {
if (dttm.getMonthOfYear() == 2) { // February is month 2!!
return dttm.getDayOfMonth() > 26;
}
return dttm.getDayOfMonth() > 28;
}
public Days daysToNewYear(LocalDate fromDate) {
LocalDate nwy = fromDate.plusYears(1).withDayOfYear(1);
return Days.daysBetween(fromDate, nwy);
}
public boolean isRentalOverdue(DateTime dttmRented) {
Period rntprd = new Period().withDays(2).withHours(12);
return dttmRented.plus(rntprd).isBeforeNow();
}
public String getBirthMonthText(LocalDate dateOfBirth) {
return dateOfBirth.monthOfYear().getAsText(Locale.ENGLISH);
}
Bookmarks