I need to get the first date (as org.joda.time.LocalDate) of a month and the last one. Getting the first is trivial, but getting the last seems to need some log
An old question, but a top google result when I was looking for this.
If someone needs the actual last day as an int instead using JodaTime you can do this:
public static final int JANUARY = 1;
public static final int DECEMBER = 12;
public static final int FIRST_OF_THE_MONTH = 1;
public final int getLastDayOfMonth(final int month, final int year) {
int lastDay = 0;
if ((month >= JANUARY) && (month <= DECEMBER)) {
LocalDate aDate = new LocalDate(year, month, FIRST_OF_THE_MONTH);
lastDay = aDate.dayOfMonth().getMaximumValue();
}
return lastDay;
}