get last day of month java code example

Example 1: get day from date month year java

Calendar cal = Calendar.getInstance();
cal.set(year,month-1,day);
int nd = cal.get(Calendar.DAY_OF_WEEK);

Example 2: Get the last day of a month in Java

LocalDate now = LocalDate.now();

LocalDate lastDay = now.with(TemporalAdjusters.lastDayOfMonth());

Example 3: get last day of month java

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
Date lastDayOfMonth = cal.getTime();

Tags:

Sql Example