import java.time.LocalDate; public class Main { public static void main(String[] argv) { System.out.println(endOfMonth(LocalDate.now())); } /** * Creates a new date object with the last day of the same month as the given * date. */ public static LocalDate endOfMonth(LocalDate date) { return date.withDayOfMonth(date.lengthOfMonth()); } }