public static LocalDate getStartOrEndDayOfMonth(LocalDate date, Boolean first) {
LocalDate resDate = LocalDate.now();
if (date == null) {
date = resDate;
}
Month month = date.getMonth();
if (first) {
resDate = LocalDate.of(date.getYear(), month, 1);
} else {
int length = month.length(date.isLeapYear());
resDate = LocalDate.of(date.getYear(), month, length);
}
return resDate;
}