import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args)throws Exception {
String date = "20210101";
LocalDate lastDayOfMonth = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyyMMdd"))
.with(TemporalAdjusters.lastDayOfMonth());
System.out.println(lastDayOfMonth);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: