Java examples for java.time:Month
Returns LocalDate date of the last day of month to which provided date belongs to.
//package com.java2s; import java.time.LocalDate; public class Main { /**//from w ww. j av a2 s. c o m * Returns {@link LocalDate} date of the last day of month to which provided {@code date} belongs to. */ public static LocalDate getMonthLastDay(LocalDate date) { int daysInMonth = date.getMonth().length(date.isLeapYear()); return date.withDayOfMonth(daysInMonth); } }