We would like to know how to get day of week for the last day of each month in 2010 with TemporalAdjuster.
/*w ww . j av a2s. co m*/ import java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] argv) { List<DayOfWeek> list = new ArrayList<>(); for (Month month : Month.values()) { DayOfWeek day = LocalDate.now().withYear(2010).with(month) .with(TemporalAdjusters.lastDayOfMonth()).getDayOfWeek(); list.add(day); } System.out.println(list); } }
The code above generates the following result.