First day of next month with java Joda-Time

   LocalDate today = new LocalDate();
   LocalDate d1 = today.plusMonths(1).withDayOfMonth(1);

A little easier and cleaner, isn’t it? 🙂

Update: If you want to return a date:

return new Date(d1.toDateTimeAtStartOfDay().getMillis());

but I strongly advise you to avoid mixing pure DATE types (i.e. a day in the calendar, without time information) with DATETIME types, specially with a “physical” datetime type as is the hideous java.util.Date . It’s somewhat like converting from-to integer and floating types, you must be careful.

Leave a Comment