Java LocalDate set to last day of month

Description

Java LocalDate set to last day of month

import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;

public class Main {
  public static void main(String[] args) {
    LocalDate today = LocalDate.now();
    System.out.println("Today: " + today);

    // Use a DateAdjuster to adjust today's date to the last day of month
    LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
    System.out.println("Last day of month: " + lastDayOfMonth);

  }//from   ww w  .  j a  v a 2 s.c  om
}



PreviousNext

Related