ChronoLocalDate with(TemporalAdjuster) Method in Java with Examples

with(TemporalAdjuster adjuster) method of the ChronoLocalDate interface used to adjusted this date-time using TemporalAdjuster passed as parameter and after adjustment returns the copy of adjusted date-time.The adjustment takes place using the specified adjuster strategy object. This instance of ChronoLocalDate is immutable and unaffected by this method call.


public ChronoLocalDate with(TemporalAdjuster adjuster)

Parameters: This method accepts adjuster as parameter which is the adjuster to use.

Return value: This method returns a ChronoLocalDate based on this with the adjustment made.

Exception: This method throws following Exceptions:

  • DateTimeException – if the adjustment cannot be made.
  • ArithmeticException – if numeric overflow occurs.

Below programs illustrate the with() method:

Program 1:





// Java program to demonstrate
// ChronoLocalDate.with() method
import java.time.*;
import java.time.temporal.*;
import java.time.chrono.*;
public class GFG {
    public static void main(String[] args)
        // create a LocalDate object
        ChronoLocalDate local
            = LocalDate.parse(
        // print instance
        System.out.println("ChronoLocalDate before"
                           + " adjustment: "
                           + local);
        // apply with method of LocalDate class
        ChronoLocalDate updatedlocal
            = local.with(Month.MARCH)
        // print instance
        System.out.println("ChronoLocalDate after"
                           + " adjustment: "
                           + updatedlocal);



ChronoLocalDate before adjustment: 2018-12-06
ChronoLocalDate after adjustment: 2018-03-31


Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.